cancel
Showing results for 
Search instead for 
Did you mean: 
jeesshnasree
Flight Engineer
Flight Engineer
  • 15.2K Views

Find out white space or blank space in any file abc.txt or abc.xml

Jump to solution

Hi all,

 could you please let me know for find/check white or blank space in a file.

how to view line number in file.xxx without open the the file.xxx with vi editor  

i am waiting for your valuable reply 

0 Kudos
2 Solutions

Accepted Solutions
Scott
Starfighter Starfighter
Starfighter
  • 15.2K Views

Take the cat to the vet!

cat -vet <filename>

It'll show you special characters for non-space whitespace, like ^T for tab and the like.  Anything that's an actual space will be shown as a space.  

I wish I had known about cat -vet as an undergrad comp-sci student.  I spent hours and hours going through a several thousand line long c program to find a ^G once using octal dump (od -c), it was quite painful, where as cat -vet would have been much faster and easier.

-STM

--
Manager, Technical Marketing
Red Hat Enterprise Linux
Red Hat Certified Engineer (100-000-264)

View solution in original post

DavidOBrien
Starfighter Starfighter
Starfighter
  • 15.2K Views

For this example file:

$ cat my-script
# The first line of text
# The second line
ALineWithNoSpaces
More spaces here
NoSpaces

I run the following command, and get the subsequent output:

$ egrep -n [[:space:]] my-script
1:# The first line of text
2:# The second line
4:More spaces here

Lines 1, 2, & 4 have spaces, but lines 3 & 5 do not. You don't need to open an editor, as you requested. For other types of white space, you'll need to modify [[:space:]]

 

Hope this helps

David

 

View solution in original post

0 Kudos
6 Replies
DavidOBrien
Starfighter Starfighter
Starfighter
  • 15.2K Views

`egrep -n [[:space:]] filename`

You might need to update that depending on what type of whitespace you want to find.

hth

David

jeesshnasree
Flight Engineer
Flight Engineer
  • 15.2K Views

hi David,

 

could you please any example . actually i tried your command and output not able to understand.

 

thanks for your help.

0 Kudos
DavidOBrien
Starfighter Starfighter
Starfighter
  • 15.2K Views

For this example file:

$ cat my-script
# The first line of text
# The second line
ALineWithNoSpaces
More spaces here
NoSpaces

I run the following command, and get the subsequent output:

$ egrep -n [[:space:]] my-script
1:# The first line of text
2:# The second line
4:More spaces here

Lines 1, 2, & 4 have spaces, but lines 3 & 5 do not. You don't need to open an editor, as you requested. For other types of white space, you'll need to modify [[:space:]]

 

Hope this helps

David

 

0 Kudos
jeesshnasree
Flight Engineer
Flight Engineer
  • 15.1K Views

Thanks David

0 Kudos
Scott
Starfighter Starfighter
Starfighter
  • 15.2K Views

Take the cat to the vet!

cat -vet <filename>

It'll show you special characters for non-space whitespace, like ^T for tab and the like.  Anything that's an actual space will be shown as a space.  

I wish I had known about cat -vet as an undergrad comp-sci student.  I spent hours and hours going through a several thousand line long c program to find a ^G once using octal dump (od -c), it was quite painful, where as cat -vet would have been much faster and easier.

-STM

--
Manager, Technical Marketing
Red Hat Enterprise Linux
Red Hat Certified Engineer (100-000-264)
jeesshnasree
Flight Engineer
Flight Engineer
  • 15.2K Views

finally thanks Scott . it seems working 

0 Kudos
Join the discussion
You must log in to join this conversation.