Gentoo Archives: gentoo-user

From: Neil Bothwick <neil@××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Simple command line stuff
Date: Mon, 10 Oct 2005 08:05:09
Message-Id: 20051010085955.40c5b843@hactar.digimed.co.uk
In Reply to: [gentoo-user] Simple command line stuff by Mark Knecht
1 On Sun, 9 Oct 2005 19:06:53 -0700, Mark Knecht wrote:
2
3 > I don't have a single book on Linux. (Amazing...) Can someone
4 > recommend a simple book on command line stuff, or better yet a good
5 > web site on this topic?
6
7 In addition to the resources already mentioned, there is an easy
8 introduction to the command line at http://www.linuxcommand.org/
9 >
10 > For instance, I wanted to run a specific command on every file in a
11 > directory which will create a new file, so I need to do
12 >
13 > command file1.wav file1-convert.wav
14
15 for f in *.wav; do command "$f" "$(basename '$f' .wav)-convert.wav"; done
16
17 > I need to take each name, create a new name to build the actual
18 > command that gets run and then do that for every file in the
19 > directory, or even in a hierarchy of directories.
20
21 This works for a single directory, to recurse you'd need something like
22 find.
23
24 find somedir -name '*.wav' | while read f; do \
25 command "$f" "$(dirname '$f')/$(basename '$f' .wav)-convert.wav"; \
26 done
27
28
29 --
30 Neil Bothwick
31
32 Acute sufferer of B5 deprivation syndrome; Owner of redundant television .