scripting - run a script in multiple folders in bash -
i have folder cabo_verde, , inside folder have several folders (001 300) several files each, this:
filename: cabo_verde
001 2008.001.00.00.cvbr1.lhz.sac 2008.001.00.00.cvbr2.lhz.sac ... 002 2008.002.00.00.cvbr1.lhz.sac 2008.002.00.00.cvbr2.lhz.sac ...
i want run script in each folder , did:
for dir in `ls $cabo_verde`; subdir in `ls $cabo_verde/$dir`; $(for file in *sac; sac <<eof echo on read $file chnhdr kcmpnm lhz write on quit eof done) done; done
in end got
ls:cannot access /001: no such file or directory ls:cannot access /002: no such file or directory
can me please?
thanks
as reliability aid, suggest writing , running scripts set -u
, parameter name typo obvious.
you want run script in each directory, true? anyway...
you can either nest 2 loops this:
for d in cabo_verde/*/; cd $d f in *.sac; sac ... $f done done
or can single loop this:
for f in cabo_verde/*/*.sac; cd ${f%/*} sac ... $f done
of course, don't need loops @ all:
find cabo_verde -name \*.sac -execdir tool
where tool
script containing sac ... < $1
Comments
Post a Comment