bash scripting help

Jason Gurtz jason at
Thu Mar 24 14:52:00 PST 2005

An interesting problem...

On 3/24/2005 04:19, Sébastien Maerten wrote:

> I need to store the following information in variables: file name, file 
> size, date/time, camera model, resolution. I'm doing it this way :
> for FILE in *.{jpg,JPG} ; do
>      jhead $FILE > temp
>      EXIF_NAME=`cat temp | grep "File name"  | cut -f 7 -d ' '`


I think the find/awk solution (or, tee hee, perhaps a du -sS | awk '{print
$2}' | awk... solution) is good.

The suggestion of perl (or python or ruby) is also probably a good idea.
I think it depends on what you really want to do with the output (are you
going to move files around via the results?).

I recently tried to create a bash script that used arrays and got stymied
by (i think) bashes quoting needs.  It just couldn't cope with multiple
piped commands and etc... in a for loop construct.  After banging my head
for a couple hours trying all sorts of unique ways of minimizing the
quoting and etc... I realized that I would be done already in perl  :)  In
particular, I'm thinking a 2D array would be ideal for this exercise (bye,
bye bash) and then you could do what ever by sorting the (in RAM) array
first and then moving files around via that or just outputting the array
to a file.

I'm not really intending to plug Perl so badly here but there's exiftool
<> which happens to be written in
Perl.  I think it could be extended with a custom command line option to
output just the things you need in whatever way.  Then again, I looked at
jhead and it's not too bad, you could modify that too, they both look like
they support recursive processing.  I guess it depends on if you want to
modify C or Perl.



More information about the lfs-chat mailing list