Mark Knecht wrote:

On 10/10/05, Spider (D.m.D. Lj.) <[EMAIL PROTECTED]> wrote:
On Sun, 2005-10-09 at 19:06 -0700, Mark Knecht wrote:
Hi,
  I don't have a single book on Linux. (Amazing...) Can someone
recommend a simple book on command line stuff, or better yet a good
web site on this topic?

  For instance, I wanted to run a specific command on every file in a
directory which will create a new file, so I need to do

command    file1.wav    file1-convert.wav

I need to take each name, create a new name to build the actual
command that gets run and then do that for every file in the
directory, or even in a hierarchy of directories.

Thanks,
Mark

For bash / zsh and other advanced(?-) shells:

for f in *.wav; do command "$f" "${f/.wav/-convert.wav}";done

The " " are there to prevent files with spaces in them (evil!) from
becoming too annoying and appearing as multiple commandline arguments.


//Spider


Thanks to all for the great answers and pointers. I appreciate it very much.

Cheers,
Mark

And just one more point. The "for" loop is shell dependent and works in sh and its cousins. But if you're using a csh based shell, it's "foreach". Now I'm not commenting on what shells are better than others but just wanted to make the point for anyone who might follow this thread in the future.

Oh, and another thought. The "find" command can do this for you as well, IIRC.

Cheers,

Drew
--
[email protected] mailing list

Reply via email to