grep: excluding lines that begin with a blank character
I have a text file where some lines have a character at the beginning and some lines don't. I want to print the text file to screen, excluding the lines that don't have a character at the beginning.
Can I do this with grep?
"excluding the lines that don't have a character at the beginning"
is same as
"including the lines that have the character at the beginning"
To get all the lines that start with char s
you can do:
grep '^s' filename
Example:
[23:18:03][/tmp]$ cat test
stack
overflow
testing
sample
[23:21:37][/tmp]$ grep '^s' test # To list lines beginning with s
stack
sample
精彩评论