Re: mv xrags and cp



Florian Diesch <diesch@xxxxxxxxxxxxx> writes:

See my answer to the same mail.


If you want do it with a loop use a while loop:

find olddir -name '*.jpg | while read fname; do
do_something_with_file $fname
done

This works as long as there's no linebreak in a filename


Nope.

find olddir -name '*.jpg | while read fname; do

breaks on leading white space (typo ignored),

do_something_with_file $fname

breaks on any white space whatsoever.

find olddir -name '*.jpg' | while IFS= read fname; do
do_something_with_file "$fname"
done

or use the canonical version which imposes no restrictions at oll on
file names:

find olddir -name '*.jpg' -exec do_something_with {} \;



--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



Relevant Pages

  • Re: reading file list, writing to text file
    ... fname %check it is reading all files ... The reason your loop is overwriting the previous text file is that you ... you should not open the file for reading multiple times - that is ... count = fprintf(fid, myfname); ...
    (comp.soft-sys.matlab)
  • Re: Variable value in while loop
    ... > declare -i size ... > while read size fname; ... > Inside a while loop all variable values are echoed OK, ... > because of the pipe agter awk. ...
    (comp.unix.shell)
  • Re: Problem using FileUtils to sort JPEG files
    ... of the for loop and only doing it once, ... Dir.glob.each do |fname| ... new scope. ... FileUtils.move(fname, "#{workdir}/#{filetype}") #workdir is ...
    (comp.lang.ruby)
  • Re: Question about For/Next loops
    ... The reason for clarifying the next in a for next loop is when ... If you had thirty lines of code and a second "for next" loop somewhere in ... Dim cnn As ADODB.Connection: ... (And White space is probably the most useful tool in any readiblity ...
    (microsoft.public.vb.enterprise)
  • Re: Print to new file for each results
    ... On 08/29/2006 06:32 PM, Ron McKeever wrote: ... My goal instead of having all the data in one big file is to loop this and create a file for each result. ... $fname = catfile; ...
    (perl.beginners)

Loading