當文件內容較多時,從頭開始顯示文件內容(enter往后看一行,空格往下翻頁B往回翻頁按q鍵退出)
管道
把左邊返回的數據交給右邊處理
grep命令:文本搜索(相當於ctrl+F)
1.查找帶有指定文本的內容
2.查找指定文本在哪一行
grep -n 搜索文本 指定文件
3.不區分大小寫搜索
grep -i 搜索文本 指定文件
4.查找當前目錄下有那些文件中包含hello
grep -n 查找內容 . -r
5.在文件中查找以D開頭的內容
grep -n ^D 4.txt
6.在文件中查找以O結尾的文本
grep - n o$ 4.txt
grep 查找文件內容總結:
grep hello test.txt 在某個文件中查找包含hello的內容,只要一行中有hello會把整行顯示
grep -niv hello test.txt n顯示查找到的內容的行號,i查找時不區分大小寫,v反向查找,查找不包含hello的行
grep -n hello /home/admin -r查找整個目錄下的所有文件
find:查找文件
grep:查找文件內容
find:find . -name 2.txt(find+目錄+-name+要找的文件名)
find /home -name 1.txt (在/home目錄下,查找文件名為1.txt的文件 )
find /home -name ‘*txt’ (在/home目錄下查找以txt結尾的文件 )