1 |
On Sunday 14 December 2008 01:49:50 Mick wrote: |
2 |
> Hi All, |
3 |
> |
4 |
> Is there a clever way to enter a string (rather than write a script file) |
5 |
> so that md5sum will check a whole series of files in one go and report |
6 |
> success or error; I was thinking along the lines of if $value is ... then |
7 |
> md5sum -c ..., but my non-existent scripting knowledge won't take me any |
8 |
> further. I want it to check a series of files named tokena, tokenb, |
9 |
> tokenc, ... , etc. |
10 |
|
11 |
You are not being very clear about what you want. When you say "check", what |
12 |
does that mean? Do you want to test if the files are OK? Then you would |
13 |
already have the md5sums so you should use md5sum -c |
14 |
|
15 |
To generate the sums, just run md5sum <filename> |
16 |
|
17 |
In any event, I think you need a fancy for loop. To run the same command on |
18 |
every file in a directory: |
19 |
|
20 |
for I in * ; do <your command here> ; done |
21 |
|
22 |
for a list of named files: |
23 |
|
24 |
for I in file1, file2 ; do <command> ; done |
25 |
|
26 |
for a list of files with a clear name structure: |
27 |
|
28 |
for I in a b c d ; do <command> token${I} ; done |
29 |
or |
30 |
for I in $(seq 1 10) ; do <command> token${I} ; done |
31 |
|
32 |
The last two are insanely useful. Replace <command> with whatever you need to |
33 |
be run over and over |
34 |
|
35 |
-- |
36 |
alan dot mckinnon at gmail dot com |