Grant asks:
> >> > cd dir1
> >> > for i in *jpg
> >> > do
> >> > j = basename $i .jpg
> >> > cp -u ${j}.jpg dir2/${j}_original.jpg
> >> > done
> >> >
> >> > 'cp -u' works around the messy problem of checking if the
> >> > destination file exists
[...]
> I put the above script in a file, added the appropriate header, issued
> chmod, and when I execute with ./file I get a bunch of these:
>
> ./script: line 6: j: command not found
> cp: cannot stat `.jpg': No such file or directory
This:
j = basename $i .jpg
should be more like this:
j=$( basename $i .jpg )
Or: j=${i%.jpg}
That is, there must be no whitespace around the '='. And in order to set j
to the result of a command, use $( command ) or ` command `.
Wonko
--
[email protected] mailing list