Re: [gentoo-user] Simple command line stuff
On Tue, 2005-10-11 at 00:25 -0700, Drew Tomlinson wrote: Oh, and another thought. The find command can do this for you as well, IIRC. find . -type f -iname '*.wav' -exec command {} {}.foo \; is the syntax, IIRC. Note the \ that exists to escape the semicolon, therefore telling find to end processing. find . -type f -iname '*.wav' |while read LIST; do command ${LIST} ${LIST/old/new} ; done is another possibility.Adding limiters to find can prevent it from recursing too deeply. //Spider -- begin .signature Tortured users / Laughing in pain See Microsoft KB Article Q265230 for more information. end signature.asc Description: This is a digitally signed message part
Re: [gentoo-user] Simple command line stuff
On Sun, 9 Oct 2005 19:06:53 -0700, Mark Knecht wrote: 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? In addition to the resources already mentioned, there is an easy introduction to the command line at http://www.linuxcommand.org/ 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 commandfile1.wavfile1-convert.wav for f in *.wav; do command $f $(basename '$f' .wav)-convert.wav; done 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. This works for a single directory, to recurse you'd need something like find. find somedir -name '*.wav' | while read f; do \ command $f $(dirname '$f')/$(basename '$f' .wav)-convert.wav; \ done -- Neil Bothwick Acute sufferer of B5 deprivation syndrome; Owner of redundant television . pgp3ILj6DlzCZ.pgp Description: PGP signature
Re: [gentoo-user] Simple command line stuff
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 commandfile1.wavfile1-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 -- begin .signature Tortured users / Laughing in pain See Microsoft KB Article Q265230 for more information. end signature.asc Description: This is a digitally signed message part
Re: [gentoo-user] Simple command line stuff
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 commandfile1.wavfile1-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 -- gentoo-user@gentoo.org mailing list
[gentoo-user] Simple command line stuff
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 commandfile1.wavfile1-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 -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] Simple command line stuff
Mark Knecht ([EMAIL PROTECTED]) scribbled: 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? Sorry, I picked up most of it from fiddling around, but on to your problem... 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 commandfile1.wavfile1-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. # for file in `ls *.wav` do newname=`echo ${file} | sed -e s/\.wav$/-convert.wav/` command -i ${file} -o ${newname} done chug...chug...chug and it's done. But this will only work on files in one subdirectory. For recursive operations, replace the first line with this: # for file in `find . -type f -iname *.wav -print` hth, jason. -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] Simple command line stuff
There is a online, downloadable Advanced Bash at http://www.tldp.org/LDP/abs/html/ Which is well worth it. I printed it out and refer to it. There are others that I found with a search for Advanced Bash but I haven't tried them. On Sun, 9 Oct 2005, 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 commandfile1.wavfile1-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 -- Brett I. Holcomb [EMAIL PROTECTED] Registered Linux User #188143 Remove R777 to email -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] Simple command line stuff
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 commandfile1.wavfile1-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 If you want THE book on command line stuff, I would highly recommend the book UNIX Power Tools published by O'Reilly. It basically goes over every common UNIX command line tool and covers the common/useful tasks you might want to do with it. It's a very thick book, but don't be intimidated by its size,you can read just the sections you need. It's basically a recipe book. As far as a website, a decent tutorial for shell scripting is available at: http://www.tldp.org/LDP/abs/html/ -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] Simple command line stuff
Daniel Lynch ([EMAIL PROTECTED]) scribbled: If you want THE book on command line stuff, I would highly recommend the book UNIX Power Tools published by O'Reilly. It basically goes over every common UNIX command line tool and covers the common/useful tasks you might want to do with it. It's a very thick book, but don't be intimidated by its size,you can read just the sections you need. It's basically a recipe book. As far as a website, a decent tutorial for shell scripting is available at: http://www.tldp.org/LDP/abs/html/ oops, I totally forgot about that, # emerge -av abs-guide hth, jason. -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] Simple command line stuff
http://rute.2038bug.com/index.html.gz On Sun, 9 Oct 2005 19:06:53 -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 commandfile1.wavfile1-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 -- gentoo-user@gentoo.org mailing list -- Nick Rout [EMAIL PROTECTED] -- gentoo-user@gentoo.org mailing list