in reply to One-liner (or few-liner) for massaging regexps?

use df -m to get megabytes? :)

Oh, you mean in perl...

perl -pe's{(\d+)}{($1>1024)?(int($1/1024)):$1}eg;'
The only problem with this is that what you replace isn't going to be the same width as what you removed, which could mess up columns.
perl -pe's{(\d+)}{($1>1024)?(sprintf("%".length($1)."d",$1/1024)):$1}e +g;'

--
Mike

Replies are listed 'Best First'.
Re^2: One-liner (or few-liner) for massaging regexps?
by Aristotle (Chancellor) on Sep 17, 2002 at 21:28 UTC
    That variable sprintf can be easier written as perl -pe's{\b(\d+)\b}{ sprintf "%*d", length $1, $1/1024 }ge' Update: added \bs - thanks to sauoq.

    Makeshifts last the longest.