argument in awk takes on the argument passing into bash script — oracle-tech

    Forum Stats

  • 3,714,551 Users
  • 2,242,575 Discussions
  • 7,844,930 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

argument in awk takes on the argument passing into bash script

User_U1UYA
User_U1UYA Member Posts: 24 Red Ribbon

Hi everybody,

To run my script: myscript copy -t "2011-11-11" -s 3

<-- the 2nd $OPTARG is "2011-11-11", so inside the script the awk calls for $2 and it took up the argument passed in instead of the 2nd column from free -g.

oth=$(free -g | grep 'Mem' | awk '{print $2}')

Please help.


Thanks

Answers

  • Herbert van den Bergh-Oracle
    Herbert van den Bergh-Oracle Member Posts: 969 Employee

    Can you attach your script here please. It doesn't look like you posted enough of it here to understand what is going on. It looks like there may be a quoting issue that is causing the $2 to get expanded by the shell, but we'd have to see the surrounding code to understand why.

Sign In or Register to comment.