Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

how do I display the average file size (rounded down). Use only: cat, echo, ls, wc, here is what I was able to do so far: echo "$(cat * | wc -w; ls -l | wc -l)" I have both of the numbers, I just can't divide them, any help would be appreciated and thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
177 views
Welcome To Ask or Share your Answers For Others

1 Answer

Is it allowed to use the shell for the division?

$ ls -l
total 20
-rw-r--r-- 1 james james  968 Dec 29  2016 bar
-rw-r--r-- 1 james james  900 Dec 29  2016 bar.asc
-rw-r--r-- 1 james james   39 Dec 29  2016 compr.txt
-rw-r--r-- 1 james james 1056 Dec 28  2016 foo
-rw-r--r-- 1 james james  896 Dec 29  2016 foo.asc
$ cat * | wc -c
3859
$ ls | wc -l
5
$ echo $(( $(cat * | wc -c) / $(ls | wc -l) ))      # solution part
771
$ echo 5*771 | bc 
3855

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...