Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk not returning correctly value 1

Status
Not open for further replies.

mregotman

Instructor
Mar 20, 2011
6
US
// returns the right value of "Parent"
dansguardian -s | awk '{print $1}'

//returns the right value of "DansGuardian"
dansguardian -s | awk '{print $2}'

//returns the right value of "pid:65273"
dansguardian -s | awk '{print $3}'

but as soon as I put these commands in a bash script ...no matter if I use print $1 or print $2 or
print $3 ..

it will ALWAYS return the value "Parent" ..no clue why ..here is my code ...

var=(`dansguardian -s`' | awk {print $2}')
echo $var

var2=(`dansguardian -s`' | awk {print $3}')
echo $var2

Its stuck stupid on "Parent" ..never changes ..for whatever reason ..any suggestions or tips are appreciated ..thanks
 
Try

var=`dansguardian -s | awk '{print $2}'`

CaKiwi
 
CaKiwi,

Thanks!!!!!!!!! I tried so many variations..

Thanks again!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top