[Gllug] Shell script to sort filenames

Manjush G. Menon manjush at lycos.co.uk
Fri Dec 27 10:13:14 UTC 2002


hi tim
though i didnt test it out, 
thanks a lot for your help
Have a great day

~~ Manjush

   .^.    .---------------------------------------------.
   /V\    | Manjush G. Menon | http://www.manjush.da.ru |
 /(   )\  | Linux Registered user #288871               |
  ^^-^^   `---------------------------------------------'

Sr. Programmer,
Sofker Solutions Pvt Ltd,
Kochi-18, INDIA.
----- Original Message ----- 
From: "t.clarke" <tim at seacon.co.uk>
To: <gllug at linux.co.uk>
Sent: Friday, December 27, 2002 3:42 PM
Subject: [Gllug] Shell script to sort filenames


> MANJUSH  wrote concerning a shell script to sort file-names within several
> directories into alphabetical order 
> 
> I am not totally sure if the following does what is required, but you can
> try it.   The script is crude, but it appears to work
> Invocation is simply:
> script-name   -f  directory1 directory2 ...... 
> or
> script-name   -r  directory1 directory2 ...... 
> 
> 
> Tim
> 
> 
> if [ $# -lt 2 ]
> then
> echo "insufficient parameters; must be -f[r] and at least one directory"
> exit
> fi
> A=$#
> ORDER=$1
> if [ $ORDER != "-r" -a $ORDER != "-f" ]
> then
> echo "sort order not specified (-f or -r)"
> exit
> fi
> cat /dev/null > /tmp/sort
> A=`expr $A - 1`
> while [ $A -gt 0 ]
> do
> A=`expr $A - 1`
> shift 1
> echo "$1"
> ls "$1" >> /tmp/tosort
> done
> sort $ORDER /tmp/tosort > /tmp/sorted
> rm /tmp/tosort
> 
> -- 
> Gllug mailing list  -  Gllug at linux.co.uk
> http://list.ftech.net/mailman/listinfo/gllug
> 
> .


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list