Linux shell文件及文本處理指令總結(jié)
《跟老男孩學(xué)linux運(yùn)維讀書筆記》
cat 顯示文本
$ cat file1.txt file2.txt > file.txt #文本合并$ cat > file <<EOF # 文本編輯(刪除原內(nèi)容并修改) > edit your content > EOF$ cat >> file.txt <<EOF #文本追加 > add your content >EOF$ cat -n file.txt #顯示行編號(hào)
tac 反向輸出(僅行反向)
$ tac file.txt
more/less 分頁(yè)顯示
$ more file.txt$ less file.txt
head 顯示文件頭
$ head file.txt #默認(rèn)顯示頭10行 $ head -n 5 file.txt #顯示頭5行 $ head -c 10 file.txt #顯示頭10個(gè)字節(jié)
tail 顯示文件尾
$ tail file.txt #默認(rèn)顯示尾10行 $ tail -n 5 file.txt #顯示尾5行 $ tail -5 file.txt #顯示為5行,與上面等價(jià) $ tail -n +15 file # 從第15行開始顯示