Gentoo Archives: gentoo-user

From: Zac Slade <krakrjak@××××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] shell script
Date: Tue, 18 Apr 2006 05:52:09
Message-Id: 200604180047.48347.krakrjak@volumehost.net
In Reply to: [gentoo-user] shell script by scwang@ios.ac.cn
1 On Tuesday 18 April 2006 00:34, scwang@××××××.cn wrote:
2 > In a shellp script, let
3 > STRING="a.txt b.txt c.txt"
4 > And I want to delete a sub-string from $STRING, for example
5 > b.txt, and then we got
6 > $STRING is "a.txt c.txt"
7 >
8 > How to achieve it?
9 >From man bash:
10 ${parameter:-word}
11 Use Default Values. If parameter is unset or null, the expansion of word is
12 substituted. Otherwise, the value of parameter is substituted.
13
14 So for what you want just do:
15 STRING="a.txt b.txt c.txt"
16 ${STRING:-b.txt}
17
18 There are tons of ways to manipulate "parameters" and you should reference the
19 man page for more. Look under "Parameter Expansion" for all the
20 possibilities.
21 --
22 Zac Slade
23 krakrjak@××××××××××.net
24 ICQ:1415282 YM:krakrjak AIM:ttyp99
25
26 --
27 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] shell script Benno Schulenberg <benno.schulenberg@×××××.com>