On 24.09.2010 22:03, Boyd Stephen Smith Jr. wrote:
In<20100924141439.gn15...@wasteland.homelinux.net>, Jochen Schulz wrote:
Enrico Weigelt:
do_rm() {
while read FILE ; do rm -fr $FILE ; done
}
That won't work with spaces in filenames. :) "find … -exec" or "find …
-print0 | xargs -0" are the best ways to do this. Apart from "find …
-delete" which I regularly forget. :)
Actually, that *will* work with spaces in the filenames[1], since the shell
built-in read doesn't stop until end of line. There are some other, even less
common, characters that can confuse read though: '\', '"', and NL.
[1] At least with single space characters. Read might be sensitive to IFS/OFS
and merge runs of characters or translate all whitespace to space characters;
I'm not looking at the spec right now.
There might be some ppl finding this interesting:
eris:~# cat /tmp/tst
1, 2, foo bar
2, 3, bar foo
a b
a b
c d
d e
eris:~# while IFS= read -r; do echo "$REPLY"; done < /tmp/tst
1, 2, foo bar
2, 3, bar foo
a b
a b
c d
d e
eris:~# while read -r; do echo "$REPLY"; done < /tmp/tst
1, 2, foo bar
2, 3, bar foo
a b
a b
c d
d e
eris:~# while IFS= read -r foo; do echo "$foo"; done < /tmp/tst
1, 2, foo bar
2, 3, bar foo
a b
a b
c d
d e
eris:~# while read -r; do echo "$REPLY"; done < /tmp/tst
1, 2, foo bar
2, 3, bar foo
a b
a b
c d
d e
eris:~# while read -r foo; do echo "$foo"; done < /tmp/tst
1, 2, foo bar
2, 3, bar foo
a b
a b
c d
d e
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
on debian lenny.
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4ca0394d.4080...@chello.at