LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
[stats]
From: David Newall <davidn@rebel.net.au>
To : Peter Freeman <petefree@bigfoot.com>
Date: Tue, 26 Jun 2001 19:04:08 +0930 (CST)
Re: for loop (bash) with spaces in filenames
> for f in `cat /pathtolist/mp3.txt` do cp "$f" /newdirectory done
You didn't say exactly how the file is organised, so I'm going to
guess one filename per line. (Note that a filename is allowed
to contain the newline character; I'm just hoping that none of
your files do!)
Others have already pointed out that spaces can be tricky. I'm
going to show you that there really is no problem. Rather than
iterate using for, use while and read:
while read filename; do cp "$filename" /newdirectory; done < mp3.txt
Voila.
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
[stats]
Return to the LinuxSA Mailing List Information Page