Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Scheme Programming Language

scsh challenge task


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?

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

HMMM!! let me fire up scsh and give her  a go
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc