一、基础查看
cat file1
cat -n file1
cat xxx.txt awk 'NR%2==1' tac file1
more file1
less file1
head -2 file1
tail -2 file1
tail -f /log/msg
二、条件查看
grep codesheep hello.txt
grep ^sheep hello.txt
grep [0-9] hello.txt
sed -n '/s1/p' hello.txt
sed -n '1,5p;5q' hello.txt
sed -n '5p;5q' hello.txt
三、替换和删除
sed 's/s1/s2/g' hello.txt
sed '/^$/d' hello.txt
sed '/ *#/d; /^$/d' hello.txt
sed -e '1d' hello.txt
sed -e 's/ *$//' hello.txt
sed -e 's/s1//g' hello.txt
四、合并文件
paste file1 file2
paste -d '+' file1 file2
五、排序和比较
sort file1 file2
sort file1 file2
sort file1 file2
sort file1 file2
comm -1 file1 file2
comm -2 file1 file2
comm -3 file1 file2