On Sunday 14 December 2008 01:49:50 Mick wrote:
> Hi All,
>
> Is there a clever way to enter a string (rather than write a script file)
> so that md5sum will check a whole series of files in one go and report
> success or error;  I was thinking along the lines of if $value is ... then
> md5sum -c ..., but my non-existent scripting knowledge won't take me any
> further.  I want it to check a series of files named tokena, tokenb,
> tokenc, ... , etc.

You are not being very clear about what you want. When you say "check", what 
does that mean? Do you want to test if the files are OK? Then you would 
already have the md5sums so you should use md5sum -c

To generate the sums, just run md5sum <filename>

In any event, I think you need a fancy for loop. To run the same command on 
every file in a directory:

        for I in * ; do <your command here> ; done

for a list of named files:

        for I in file1, file2 ; do <command> ; done

for a list of files with a clear name structure:

        for I in a b c d ; do <command> token${I} ; done 
or
        for I in $(seq 1 10) ; do <command> token${I} ;  done

The last two are insanely useful. Replace <command> with whatever you need to 
be run over and over

-- 
alan dot mckinnon at gmail dot com

Reply via email to