On Mon, Nov 13, 2000 at 11:22:03AM +1100, DaZZa ([EMAIL PROTECTED]) wrote:
> Folks.
> 
> I know this is a little off topic, but I need some help.
> 
> I need a script which will basically run through a directory, and copy all
> files which start with the same letter of the alphabet to a destination
> directory.
> 
> For example, soemthing like this
> 
> cp a*.doc /home/ftp/pub/doc/a/
> 
> except I need it for the entire possible alphabet - AaBbCc etc.
> 
> I also know stuff all about writing shell scripts - something I've got to
> find time to read up on. Oh - I'm using bash as my shell.

Well, there's always the first line in a script which can point to
a different tool:


#!/bin/tcsh
foreach f (*)
    echo -------------------------------
    echo Working with $f
    set char = `echo $f | cut -c1`
    # gotta make it first:
    echo mkdir -p /home/ftp/pub/doc/$char
    # copy ...
    echo cp -p $f /home/ftp/pub/doc/$char
end 


jhs







-- 
People without trees are like fish without clean water!

|            __, Jobst Schmalenbach, [EMAIL PROTECTED], Technical Director|
|  _ _.--'-n_/   Barrett Consulting Group P/L & The Meditation Room P/L      |
|-(_)------(_)=  +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia|


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to