看板 Programming 關於我們 聯絡資訊
這個問題是說要能印出 該目錄下 的檔案大小總合 還有最大的檔案 和最小的檔案 (不包含子目錄) 並且只能用一行 指令(用"|"串起來) 如下 % ls -l drw-r--r-- 2 root 123 512 2007-04-25 10:48 GUNPLA -rw-r--r-- 1 root 123 104 2007-05-20 08:55 test_a -rw-r--r-- 1 root 123 104 2007-09-15 08:32 mymail -rw-r--r-- 1 root 123 12354 2007-08-03 14:58 get.sh drw-r--r-- 2 root 123 512 2007-11-25 12:03 GUNDAM_animation % ./123.sh 13586 file: mymail 104 owner: root file: get.sh 12354 owner: root 想了很久 只組合出了下面 #! /bin/sh ls -l | sort +4 -5 -r | awk '{print "file:" $9" "$5" owner:"$3}' 這樣印出來式資料夾所有的檔案的大小 即使用者 沒辦法篩到剩下 最大和最小 不知道該怎麼做才能達到最上面的要求呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.243.11
coolkevin:請善用du指令 60.250.197.250 11/02 20:46
pziyout:du --max-depth=0 `/bin/ls -1S | head -1 140.115.25.24 11/03 16:50
pziyout:` `/bin/ls -1rS | head -1` . 140.115.25.24 11/03 16:50