18 January 2009

Micro coding mystery

What does this one-liner chunk of BASH script do...?
lsof | \
  grep '/dev/[hs]d[a-d]' | \
  gawk '{ print "echo $[",$7,"/ 1024]",$9, \
    "$[",$7,"/ 10 / $(fdisk -s",$9,") ]" }' | \
  sh
A hint: we are running an instance of bzip2 -d piped to an instance of dd.
An unhint: the /10’ld be /10.24 if we weren’t limited to integer math in BASH...

No comments: