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 |