[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"find" feature request
From: |
Adam Tomjack |
Subject: |
"find" feature request |
Date: |
Mon, 2 Oct 2000 15:20:01 -0500 |
the "info find" command told me to mail suggestions to this address.
I recently used GNU find to rename a buch of files by prepending a string to
the filename. It was a pain in the ass to say the least. While I find it
amazing that anything I can think of can be done with the GNU utilities, I
think that some combinations of commands could be expressed in a simpler
form. I've stumpled upon a very awkward combination of commands that could
be cleaned up.
Find expands the string "{}" into the filename when you use -exec, however
the filenames all had a ./ in front of them. I wanted to say
$ find . -name '*' -exec mv {} Moby-{}
however this would have been equivalent to:
$ mv ./filename Moby-./filename
This obviously doesn't work. I couldn't use backticks either because they
get expanded by the shell that runs find before find gets a chance to expand
the "{}" So I had to use find to -exec a new shell whose parameters included
backticks. By doing this, the "{}" was expanded before the new shell I
invoked got a chance to work it's backtick majick. My final command was this:
$ find . -name '*' -exec sh -c "mv \`echo {} | sed s/^..//\` Moby-\`echo {}
| sed s/^..//\`" \;
>From a users standpoint, this is an absurdly complicated command and it would
have been much easier if the -printf option affected the expansion of "{}" or
if there were a new option ( say -eprintf ) separate from -printf that would
affect the "{}"
Thanks for your consideration,
Adam
--
Adam Tomjack
address@hidden
http://www.adamtj.com
- "find" feature request,
Adam Tomjack <=