Linux Useful Commands I'm Unfamiliar with

ls -l filename 列出文件rwx權(quán)限
du -h . disk use helper - 列出各個(gè)文件大小
ls -ltr list all files by modification time, sorting(t) reverse(r)
/ – search for a pattern which will take you to the next occurrence.
find folder/ -name aaa.txt Find files. You can use regex after -name.
find folder/ -type f Find all files.
find folder/ -type d File all dirs.

用簡(jiǎn)單的unix command,可以進(jìn)行一些data processing的工作。這里邊的設(shè)計(jì)哲學(xué),可以看作mapreduce的前身。

awk(=filter and print)
awk '{print $7}' file.txt |  # 將file.txt里的語(yǔ)句分割,并取出第7項(xiàng)
sort | # 排序
uniq -c | # 去重,并打印出每個(gè)record的計(jì)數(shù)
sort -r -n | # 反向排序,其中-n表示以每個(gè)record開頭的數(shù)字來進(jìn)行排序
head -n 5 # 只輸出前五項(xiàng)

awk '{print length($1), $2}' text1.txt # print the len of first and second columns with whitespace as delimiter
$(NF-1) # the second last column
awk `NR==2, NR==5 {print $0}` text1.txt # get the second to fifth row 
awk `NR==2; NR==5 {print $0}` text1.txt # get the second and fifth row 
awk -F ";" '{print $1}' a.txt # change delimiter(field) to ;
awk '$2~/usa|italian/ {print $2, $4}' a.txt # // is regex. $2~ only looks in the second column.
awk '$1==$3 {print}' a.txt # search first and third column the same
sed
grep(=search)
grep -i so a.txt # search for case insensitive occurrences of "so" in a.txt
ls | grep t  # search for all files with word "t"
ls | grep -v t  # search for all files without word "t"
sort
uniq
xargs

Reference:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 這篇文章翻譯自http://www.thegeekstuff.com/2010/11/50-linux-comma...
    sufun_wu閱讀 847評(píng)論 0 4
  • cat cdchmod chowncp cut名稱:cat使用權(quán)限:所有使用者使用方式:cat [-AbeEnst...
    Creator93閱讀 428評(píng)論 0 0
  • 目錄與路徑絕對(duì)路徑與相對(duì)路徑:略目錄的相關(guān)操作幾個(gè)特殊目錄. 代表此層目錄.. 代表上一層目錄- 代表前一個(gè)工作目...
    March_13th閱讀 585評(píng)論 1 1
  • 常用操作以及概念 求助 –help 指令的基本用法與選項(xiàng)介紹。 man man 是 manual 的縮寫,將指令的...
    Fellers閱讀 508評(píng)論 0 3
  • 1. tar 創(chuàng)建一個(gè)新的tar文件 $ tar cvf archive_name.tar dirname/ 解壓...
    dazdingos閱讀 522評(píng)論 0 0

友情鏈接更多精彩內(nèi)容