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
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
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
`egrep -n [[:space:]] filename`
You might need to update that depending on what type of whitespace you want to find.
hth
David
hi David,
could you please any example . actually i tried your command and output not able to understand.
thanks for your help.
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
Thanks David
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
finally thanks Scott . it seems working
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.