[clug] Help with bash script
Alastair D'Silva
alastair at newmillennium.net.au
Sat Nov 1 08:34:44 GMT 2008
> Well one thing to do as a start is this: (to take care of spaces).
>
> mv "${file}" ${i}
Not quite everything you need . . . the for loop will still get tripped up
on spaces. Shell expansion will expand the wildcard into a space separated
list of files, which for will then split on spaces.
Instead of the for loop, you want to use:
find -exec <script>
This will pass the filename as the first parameter to the script, which can
then track state itself by storing it in an additional file.
or
find -print0 | xargs -0 -n 10 <script> (GNU find & xargs only)
This will pass in 10 files at a time as parameters to the script.
Of course, within the script, you should enclose the variables in double
quotes as above.
--
Alastair D'Silva mob: 0423 762 819
Networking Consultant
New Millennium Networking web: http://www.newmillennium.net.au
skype: alastair_dsilva msn: alastair at d-silva.org
blog: http://alastair.d-silva.org
More information about the linux
mailing list