Link to home
Start Free TrialLog in
Avatar of Jasmin shahrzad
Jasmin shahrzad

asked on

awk to variable in bash

What i do wrong here with this command
i sat (in linux)
new=test
den i have test.log files. when i say NR==30 {print $1; exit}' $new.log from command line
get successfully first variable which is 2. but in bash file want to put this number in variable say
err=awk 'NR==30 {print $1; exit}' $new.log
get field  NR==30 {print $1; exit}: command not found
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
$(...) or the older form `...` (backticks) invoke "command substitution" which means reassigning the output of a command to (e. g.) a variable.
The $(...) form has superseded backticks for command substitution, the backticks still work, however.

See this article for a comprehensive explanation:
http://tldp.org/LDP/abs/html/commandsub.html