AWK Output into a variable

Hi

I am trying to store the output of awk into a variable in a shell script. I can run it successfully from the command line but not from a ksh shell script.

ls -al test.txt | grep -v grep | awk '{print $1}'
returns -rw-r--r--

#!/bin/ksh
perm=$(`ls -al test.txt | grep -v grep | awk '{print $1}'`)
echo $perm

returns ./test.sh[2]: -rw-r--r--: not found

Could you please tell me what I am doing wrong.

Thanks
Mace

Hi,

you are using backticks "` ... `" inside "$(...)". Thus you are
executing your code _twice_. Delete either the backticks or the
$(...) and it should work.

HTH Chris

Yes, that works.

Thanks for your help Chris. Much appreciated.