Hello,
On Thu, 12 Mar 2009, Ashish Verma wrote:
> I have a file with 2 columns. First lists the space of the folder and the
> second the folder name. Sample below:
<snip></snip>
> I do not know to work well with stream editors and regexs'.
Well, you should! Or you should learn perl which can be used to
combine everything.
Here is a solution using sed and cut. Let list be the file
that contains the data.
cat list | \
sed -e's/^/0 \1/' \
-e's/^0 \([0-9\.]*G\)/3 \1/' \
-e's/^0 \([0-9\.]*M\)/2 \1/' \
-e's/^0 \([0-9\.]*K\)/1 \1/' | \
sort -n | cut -f2- -d' '
The sed expression adds a "rank" at the top of each the line depending
on whether it is nothing or "G", "M" or "K" that is attached to the
number. The ordinary "sort -n" then works. At the end "cut" is used to
cut out the extra junk.
Regards,
Kapil.
--
_______________________________________________
To unsubscribe, email [email protected] with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc