linux - Trying to use awk to print a column but says print not found -
so trying homework , having lot of issues. first script have written in unix/linux. right trying print out few columns free command , use awk grab columns need. every time try this, bash: print command not found.
command trying use:
free | awk `{print $3}`
i have tried without {}.
so when finished example: total free memory: xx mb xx filled in of course result.
any appreciated. thanks.
update: okay don't use backticks work. whole command end saying: total free memory: xx mb
the command have far is:
echo "current free memory: " | free -m | awk '{print $3}'
i want 1 column row intersection.
you should go field 4. suggest using awk , sed you.
here suggestion :
freem="$(free -m | awk '{print $4}' | sed -n '2p')" echo "total free memory: $freem mb"
where $4 columns want , 2p line want.
before writing script, check result in command line.
Comments
Post a Comment