|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I am trying to do something in my script as follows, it sends the following output to the file hosts as follows: mgt=b01 cat >> ./hosts <<EOF # # 10.32.25.34 b01 10.32.25.35 b02 10.32.25.36 b03 EOF I want to cat the output to the hosts file but 'exclude' the line if the line has the value of the 'mgt' variable so in the above example I would get in the hosts file. # # 10.32.25.35 b02 10.32.25.36 b03 I have tried using cat with grep -v "$mgt" with no luck. I think Im redirecting something wrong. Thanks for any . |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
cconnell_1@lycos.com wrote:
> mgt=b01 > cat >> ./hosts <<EOF > # > # > 10.32.25.34 b01 > 10.32.25.35 b02 > 10.32.25.36 b03 > EOF > > [...] > > I have tried using cat with grep -v "$mgt" with no luck. This works for me: #v+ mgt=b01 grep -v "$mgt" <<EOF >>./hosts # # 10.32.25.34 b01 10.32.25.35 b02 10.32.25.36 b03 EOF #v- Cheers, -- Klaus Alexander Seistrup http://klaus.seistrup.dk/ |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
cconnell_1@lycos.com wrote: > Hi, > I am trying to do something in my script as follows, it sends the > following output to the file hosts as follows: > > mgt=b01 > cat >> ./hosts <<EOF > # > # > 10.32.25.34 b01 > 10.32.25.35 b02 > 10.32.25.36 b03 > EOF > > I want to cat the output to the hosts file but 'exclude' the line if > the line has the value of the 'mgt' variable so in the above example I > would get in the hosts file. > > # > # > 10.32.25.35 b02 > 10.32.25.36 b03 > > > I have tried using cat with grep -v "$mgt" with no luck. I think Im > redirecting something wrong. Thanks for any . It works for me: mgt=b01 cat << EOF | grep -v "$mgt" > roland.txt # # 10.32.25.34 b01 10.32.25.35 b02 10.32.25.36 b03 EOF cat roland.txt |
|
![]() |
| Outils de la discussion | |
|
|