* [gentoo-user] Simple command line stuff
@ 2005-10-10 2:06 Mark Knecht
2005-10-10 2:18 ` Jason Cooper
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Mark Knecht @ 2005-10-10 2:06 UTC (permalink / raw
To: gentoo-user
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
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 2:06 [gentoo-user] Simple command line stuff Mark Knecht
@ 2005-10-10 2:18 ` Jason Cooper
2005-10-10 2:20 ` Brett I. Holcomb
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Jason Cooper @ 2005-10-10 2:18 UTC (permalink / raw
To: gentoo-user
Mark Knecht (markknecht@gmail.com) 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
>
> 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.
# 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 2:06 [gentoo-user] Simple command line stuff Mark Knecht
2005-10-10 2:18 ` Jason Cooper
@ 2005-10-10 2:20 ` Brett I. Holcomb
2005-10-10 2:22 ` Daniel Lynch
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Brett I. Holcomb @ 2005-10-10 2:20 UTC (permalink / raw
To: gentoo-user
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
>
> 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
>
>
--
Brett I. Holcomb
brettholcomb@R777bellsouth.net
Registered Linux User #188143
Remove R777 to email
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 2:06 [gentoo-user] Simple command line stuff Mark Knecht
2005-10-10 2:18 ` Jason Cooper
2005-10-10 2:20 ` Brett I. Holcomb
@ 2005-10-10 2:22 ` Daniel Lynch
2005-10-10 2:32 ` Jason Cooper
2005-10-10 3:09 ` Nick Rout
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Daniel Lynch @ 2005-10-10 2:22 UTC (permalink / raw
To: gentoo-user
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
>
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 2:22 ` Daniel Lynch
@ 2005-10-10 2:32 ` Jason Cooper
0 siblings, 0 replies; 11+ messages in thread
From: Jason Cooper @ 2005-10-10 2:32 UTC (permalink / raw
To: gentoo-user
Daniel Lynch (more.on@sbcglobal.net) 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 2:06 [gentoo-user] Simple command line stuff Mark Knecht
` (2 preceding siblings ...)
2005-10-10 2:22 ` Daniel Lynch
@ 2005-10-10 3:09 ` Nick Rout
2005-10-10 7:59 ` Neil Bothwick
2005-10-10 9:00 ` Spider (D.m.D. Lj.)
5 siblings, 0 replies; 11+ messages in thread
From: Nick Rout @ 2005-10-10 3:09 UTC (permalink / raw
To: gentoo-user
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
>
> 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
>
> --
> gentoo-user@gentoo.org mailing list
--
Nick Rout <nick@rout.co.nz>
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 2:06 [gentoo-user] Simple command line stuff Mark Knecht
` (3 preceding siblings ...)
2005-10-10 3:09 ` Nick Rout
@ 2005-10-10 7:59 ` Neil Bothwick
2005-10-10 9:00 ` Spider (D.m.D. Lj.)
5 siblings, 0 replies; 11+ messages in thread
From: Neil Bothwick @ 2005-10-10 7:59 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1120 bytes --]
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
>
> command file1.wav file1-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 .
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 2:06 [gentoo-user] Simple command line stuff Mark Knecht
` (4 preceding siblings ...)
2005-10-10 7:59 ` Neil Bothwick
@ 2005-10-10 9:00 ` Spider (D.m.D. Lj.)
2005-10-10 14:57 ` Mark Knecht
5 siblings, 1 reply; 11+ messages in thread
From: Spider (D.m.D. Lj.) @ 2005-10-10 9:00 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]
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
--
begin .signature
Tortured users / Laughing in pain
See Microsoft KB Article Q265230 for more information.
end
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 9:00 ` Spider (D.m.D. Lj.)
@ 2005-10-10 14:57 ` Mark Knecht
2005-10-11 7:25 ` Drew Tomlinson
0 siblings, 1 reply; 11+ messages in thread
From: Mark Knecht @ 2005-10-10 14:57 UTC (permalink / raw
To: gentoo-user
On 10/10/05, Spider (D.m.D. Lj.) <spider@gentoo.org> 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
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-10 14:57 ` Mark Knecht
@ 2005-10-11 7:25 ` Drew Tomlinson
2005-10-11 8:09 ` Spider (D.m.D. Lj.)
0 siblings, 1 reply; 11+ messages in thread
From: Drew Tomlinson @ 2005-10-11 7:25 UTC (permalink / raw
To: gentoo-user
Mark Knecht wrote:
>On 10/10/05, Spider (D.m.D. Lj.) <spider@gentoo.org> 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
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [gentoo-user] Simple command line stuff
2005-10-11 7:25 ` Drew Tomlinson
@ 2005-10-11 8:09 ` Spider (D.m.D. Lj.)
0 siblings, 0 replies; 11+ messages in thread
From: Spider (D.m.D. Lj.) @ 2005-10-11 8:09 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 673 bytes --]
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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-10-11 8:16 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-10 2:06 [gentoo-user] Simple command line stuff Mark Knecht
2005-10-10 2:18 ` Jason Cooper
2005-10-10 2:20 ` Brett I. Holcomb
2005-10-10 2:22 ` Daniel Lynch
2005-10-10 2:32 ` Jason Cooper
2005-10-10 3:09 ` Nick Rout
2005-10-10 7:59 ` Neil Bothwick
2005-10-10 9:00 ` Spider (D.m.D. Lj.)
2005-10-10 14:57 ` Mark Knecht
2005-10-11 7:25 ` Drew Tomlinson
2005-10-11 8:09 ` Spider (D.m.D. Lj.)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox