2013-03-29 179 views
-1

我在shell編程方面很新穎,這是我爲我的實驗室做的作業。我真的不明白我應該做什麼以及如何做。誰能幫我?如何在shell中執行此操作?

編寫一個從指定文件夾開始的shell會顯示所有名稱的列表:它的文件和文件夾及其子目錄。 對於列表中的每個文本文件,name都會打印與該文件相同行的最大編號 以及那些行的內容。 對於列表中的每個文件夾名稱,包含文件的數量將打印爲 。

+2

你試過了嗎?請看:[http://tldp.org/LDP/abs/html/](http://tldp.org/LDP/abs/html/)。 – mkjasinski

+0

你試過了嗎?請看:http://www.tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html – plesiv

+0

您將需要基本的shell命令,您可以在上述手冊中瞭解到這些命令:ls ','wc','uniq','sort','cat'等。 – plesiv

回答

0
find $1 | while read name 
do echo $name 
    case `file $name` in 
    *text)  sort $name|uniq -c|sort -nr|head -1;; 
    *directory) find $name -maxdepth 1 -type f|wc -w;; 
    esac 
done 
+2

對於作業/作業問題,最好不要給出最終工作代碼... – Kent