Trouble with setting a variable with vastool

Hi I have this command that when put on the command line it returns the output the way I want it.

/opt/quest/bin/vastool list -a groups | grep testdev_li | grep dev | awk -F"[D:]" 'NF>2{print $2}' | cut -c2- | tr '\n' '|'

The output of this is

testdev_li2434|testdev_li4532|testdev_li2356|testdev_li2345

but when i try to set this to a variable, it gives me an error

tst=/opt/quest/bin/vastool list -a groups | grep abinitio_bi | grep developers | awk -F"[D:]" 'NF>2{print $2}' | cut -c2- | tr '\n' '|'

The error is this(name of the file is test.ksh)

test.ksh: line 3: list: not found

im kinda new to shell scripting so im not sure what to do

You need to use command substitution:

var=$(commands)
1 Like

I'd be surprised if grep dev would do anything after the grep testdev_li , and both could be incorporated into the awk command. Try

tst=$(/opt/quest/bin/vastool list -a groups | awk -F"[D:]" -vOFS="|" '/developers/ && /abinitio_bi/ && NF > 2 {print substr ($2,2)}')

If need be, add an END {printf "\n"} section.