|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
i'd like the result of the following command: $GROUPID | sed -e 's/\./\//g' to assign to a variable: TEMP="$GROUPID | sed -e 's/\./\//g'" ??? or TEMP=[$GROUPID | sed -e 's/\./\//g'] ??? What is the correct command? Thanks in advance! Daniel |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Jan 4, 10:51 pm, sorg.dan...@googlemail.com wrote:
> Hi, > > i'd like the result of the following command: > > $GROUPID | sed -e 's/\./\//g' > > to assign to a variable: > > TEMP="$GROUPID | sed -e 's/\./\//g'" ??? > or > TEMP=[$GROUPID | sed -e 's/\./\//g'] ??? > > What is the correct command? > > Thanks in advance! > Daniel backticks? TEMP=`$GROUPID | sed -e 's/\./\//g'` |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 1/4/2008 8:51 AM, sorg.daniel@googlemail.com wrote: > Hi, > > i'd like the result of the following command: > > $GROUPID | sed -e 's/\./\//g' > > to assign to a variable: > > TEMP="$GROUPID | sed -e 's/\./\//g'" ??? > or > TEMP=[$GROUPID | sed -e 's/\./\//g'] ??? > > What is the correct command? > > Thanks in advance! > Daniel The syntax is: variable=`command arguments` or: variable=$(command arguments) so you could use: TEMP=$(echo "$GROUPID" | sed -e 's/\./\//g') Using sed to do the subsitution may not be the most efficient way to do it, depending on which shell you're using, e.g. in bash: $ x="a:b:c" $ y="${x//:/,}" $ echo "$y" a,b,c so you may be able to just do: TEMP="${GROUPID//.//}" Note also that by convention all-upper-case names are only used for exported variables. Ed. |
|
![]() |
| Outils de la discussion | |
|
|