Add gallery example: dir-size
This commit is contained in:
parent
730315fd54
commit
b1f2a33eb3
1 changed files with 22 additions and 0 deletions
22
README.md
22
README.md
|
|
@ -514,6 +514,28 @@ welcome!
|
|||
find . | grep conflict | bb -i '(doseq [f *in*] (.delete (io/file f)))'
|
||||
```
|
||||
|
||||
### Calculate aggregate size of directory
|
||||
|
||||
``` clojure
|
||||
#!/usr/bin/env bb
|
||||
|
||||
(as-> (io/file (or (first *command-line-args*) ".")) $
|
||||
(file-seq $)
|
||||
(map #(.length %) $)
|
||||
(reduce + $)
|
||||
(/ $ (* 1024 1024))
|
||||
(println (str (int $) "M")))
|
||||
```
|
||||
|
||||
``` shellsession
|
||||
$ dir-size
|
||||
130M
|
||||
|
||||
$ dir-size ~/Dropbox/bin
|
||||
233M
|
||||
```
|
||||
|
||||
|
||||
### Shuffle the lines of a file
|
||||
|
||||
``` shellsession
|
||||
|
|
|
|||
Loading…
Reference in a new issue