On May 3, 5:26 pm, gavino <gavcom@gmail.com> wrote:
> du -h --max-depth=1|grep [0-9][K]|sort -n; du -h --max-depth=1|grep
> [0-9][M]|sort -n; du -h --max-depth=1|grep [0-9][G]|sort -n
> is there a simpler way to do this in scsh?
Hmm. Well the direct translation is:
(begin
(run (| (du -h --max-depth=1)
(grep "[0-9][K]")
(sort -n)))
(run (| (du -h --max-depth=1)
(grep "[0-9][M]")
(sort -n)))
(run (| (du -h --max-depth=1)
(grep "[0-9][G]")
(sort -n))))
You can at least factor out the pipeline.
(define (du-unit unit)
(let ((pattern (string-append "[0-9]" unit)))
(run (| (du -h --max-depth=1)
(grep ,pattern)
(sort -n)))))
So now it's:
(begin (du-unit "K") (du-unit "M") (du-unit "G"))
Or
(for-each du-unit '("K" "M" "G"))
Ed