cancel
Showing results for 
Search instead for 
Did you mean: 
jeesshnasree Flight Engineer
Flight Engineer
  • 632 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
Moderator
Moderator
  • 621 Views

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

Jump to solution

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

--
Principle Technical Marketing Manager, Red Hat Enterprise Linux
Red Hat Certified Engineer (100-000-264)
Reply
Loading...
Highlighted
DavidOBrien Flight Engineer
Flight Engineer
  • 583 Views

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

Jump to solution

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
Reply
Loading...
6 Replies
DavidOBrien Flight Engineer
Flight Engineer
  • 630 Views

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

Jump to solution

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

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

hth

David

Reply
Loading...
jeesshnasree Flight Engineer
Flight Engineer
  • 601 Views

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

Jump to solution

hi David,

 

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

 

thanks for your help.

0 Kudos
Reply
Loading...
Highlighted
DavidOBrien Flight Engineer
Flight Engineer
  • 584 Views

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

Jump to solution

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
Reply
Loading...
jeesshnasree Flight Engineer
Flight Engineer
  • 579 Views

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

Jump to solution

Thanks David

0 Kudos
Reply
Loading...
Moderator
Moderator
  • 622 Views

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

Jump to solution

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

--
Principle Technical Marketing Manager, Red Hat Enterprise Linux
Red Hat Certified Engineer (100-000-264)
Reply
Loading...
jeesshnasree Flight Engineer
Flight Engineer
  • 600 Views

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

Jump to solution

finally thanks Scott . it seems working 

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