grep -n ‘^a’ test.txt
在test.txt中查询a在行首的行
grep -n ‘^[a-z]’ test.txt
在test.txt中查询小写字母在行首的行
grep -n ‘^[^a-zA-Z]’ test.txt
在test.txt中查询不是字母在行首的行
注意:^ 符号,在括号[]内代表反向选择,在 [] 外则表示定位在行首
grep -n‘\.$’test.txt
在test.txt中查询a在行首的行
grep -n ‘^[a-z]’ test.txt
在test.txt中查询小写字母在行首的行
grep -n ‘^[^a-zA-Z]’ test.txt
在test.txt中查询不是字母在行首的行
注意:^ 符号,在括号[]内代表反向选择,在 [] 外则表示定位在行首
grep -n‘\.$’test.txt
在test.txt中查询以.结尾的行
注意:.有其他含义,这里加\接触其所具有的其他含义
grep -n '^$' test.txt