获取前N行
head -n 10 test.txt
sed -n '1,10p' test.txt
awk 'FNR<11' test.txt
获取文件最后N行
tail -n 10 test.txt
获取第N行到文件末尾
tail -n +10 test.txt
sed -n '10,$p' test.txt
awk 'FNR>9' test.txt
获取指定行
sed -n '10p' test.txt
sed -n '10p;11q' test.txt
awk 'FNR==10' test.txt
awk 'FNR==10 {print;exit}' test.txt
head -n 10 test.txt |tail -n 1
tail -n +10 test.txt |head -n 1
获取含有特定字符串的行
grep 'match' text.txt
sed -n '/match/p' test.txt
获取指定字符开头的行
grep '^G' test.txt
sed -n '/^G'/p' test.txt