1753747 Members
4991 Online
108799 Solutions
New Discussion юеВ

one liner

 
SOLVED
Go to solution
KevB_1
Advisor

one liner

Hi all

We want to run the following grep command and get the output read by lanadmin -x

grep -s -e PRIMARY -e STANDBY /etc/lanmon/lanconfig.ascii | awk '{print $2}' | cut -c 4-

so we get 5 6 7 8 , etc and want to run lanadmin -x for each of them
But want this on one line so can ssh it around - how do you pass the output one at a time to lanadmin ?

2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: one liner

Hi Kev:

First, let 'awk' do the work of matching and snipping:

# awk '/PRIMARY|STANDBY/ && $2~/lan/ {print substr($2,4)}' /etc/lanmon/lanconfig.ascii | while read NUM; do lanadmin -p ${NUM};done

Regards!

...JRF...
KevB_1
Advisor

Re: one liner

Many thanks that was perfect !!