- grep pattern file -- 使用正則表達式搜索文本
- grep -r pattern dir -- 遞歸使用正則表達式搜索文本
- command | grep pattern -- 以 command 輸出為文本進行正則表達式搜索
- locate file -- 查找文件
效果如下:
? anyang cat file1
Hello, anyang!
testhhhhhhhhhhhhh
rrrrrrrrrrrrrrrr
ddddddddddddd
testfsfdsccvv
? anyang grep test* file1
testhhhhhhhhhhhhh
testfsfdsccvv
? anyang grep -r test* .
./test/test1:test is a problem
./test/test3:test is nice
./file1:testhhhhhhhhhhhhh
./file1:testfsfdsccvv
? anyang cat file1 | grep test*
testhhhhhhhhhhhhh
testfsfdsccvv
? anyang locate grep
/bin/bzegrep
/bin/bzfgrep
/bin/bzgrep
/bin/egrep
/bin/fgrep
/bin/grep
/bin/zegrep
/bin/zfgrep
/bin/zgrep
/etc/alternatives/lzegrep
/etc/alternatives/lzegrep.1.gz
/etc/alternatives/lzfgrep
- tar cf file.tar file(s) -- 將 file(s) 打包成名為 file.tar 的文件
- tar xf file.tar -- 解壓 file.tar 包中的所有文件
- tar tf file.tar -- 列出 file.tar 包中的所有文件
tar 常用參數(shù)列表:
- c -- 建立壓縮文件
- t -- 列出壓縮文件中的所有文件
- x -- 解壓壓縮文件
- f -- 指定壓縮包的文件名
- z -- 有g(shù)zip屬性的
- j -- 有bz2屬性的
- w -- 每一步操作都需要確認
- v -- 顯示所有過程
效果如下:
? test ls
file1 test1 test2 test3
? test tar cf test.tar test{1..3}
? test ls
file1 test1 test2 test3 test.tar
? test mv test.tar ..
? test cd ..
? anyang ls
file1 learngit test test.tar
? anyang tar xf test.tar
? anyang ls
file1 learngit test test1 test2 test3 test.tar
? anyang tar tf test.tar
test1
test2
test3
- gzip file(s) -- 建立壓縮文件来农,并刪除原來的文件
- gzip -c file(s) > file.gz -- 建立壓縮文件并保留原來的文件
-
gzip -d file.gz -- 解壓壓縮文件哪亿,并刪除原來的壓縮文件涵妥,效果同
gunzip
效果如下:
? anyang ls
file1 learngit test
? anyang gzip file1
? anyang ls
file1.gz learngit test
? anyang touch newfile
? anyang ls
file1.gz learngit newfile test
? anyang gzip -c newfile > newfile.gz
? anyang ls
file1.gz learngit newfile newfile.gz test
? anyang gzip -d file1.gz
? anyang ls
file1 learngit newfile newfile.gz test
相關(guān)資料:
- 29個你必須知道的Linux命令: http://www.imooc.com/article/1285
- 常用命令行介紹: https://github.com/iamcoach/console/blob/master/COMMANDS.md
- 常用命令行cheet sheet: https://bbs.excellence-girls.org/topic/167
- 書籍《鳥哥的Linux私房菜》: https://book.douban.com/subject/4889838/
- Ubuntu各種技巧:http://wiki.ubuntu.org.cn/UbuntuSkills