168 csh, pipes, and find ... Great. The shell thinks curly brackets are expendable. % find . -name ’*.el’ -exec echo test -f ’{}’c \ test -f {}c test -f {}c test -f {}c test -f {}c ... Huh? Maybe I’m misremembering, and {} isn’t really the magic “substitute this file name” token that find uses. Or maybe… % find . -name ’*.el’ \ -exec echo test -f ’{}’ c \ test -f ./bytecomp/bytecomp-runtime.el c test -f ./bytecomp/disass.el c test -f ./bytecomp/bytecomp.el c test -f ./bytecomp/byte-optimize.el c ... Oh, great. Now what. Let’s see, I could use “sed…” Now at this point I should have remembered that profound truism: “Some people, when confronted with a Unix problem, think ‘I know, I’ll use sed.’ Now they have two problems.” Five tries and two searches through the sed man page later, I had come up with: % echo foo.el | sed ’s/$/c/’ foo.elc and then: % find . -name ’*.el’ \ -exec echo test -f `echo ’{}’ \ | sed ’s/$/c/’` \ test -f c test -f c test -f c ... OK, let’s run through the rest of the shell-quoting permutations until we find one that works.
Find 169 % find . -name ’*.el’ -exec echo test -f "`echo ’{}’ |\ sed ’s/$/c/’`" \ Variable syntax. % find . -name ’*.el’ \ -exec echo test -f ’`echo "{}" |\ sed "s/$/c/"`’ \ test -f `echo "{}" | sed "s/$/c/"` test -f `echo "{}" | sed "s/$/c/"` test -f `echo "{}" | sed "s/$/c/"` ...
Previous Page Next Page