![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| set variable with another variable? c shell | wxornot | Shell Programming and Scripting | 2 | 02-23-2008 12:10 PM |
| shell variable in awk | cskumar | Shell Programming and Scripting | 12 | 08-20-2007 05:41 AM |
| Shell Variable - Please help | nisha5 | Shell Programming and Scripting | 4 | 06-01-2006 01:41 AM |
| Set Path variable in c shell | hassan2 | Shell Programming and Scripting | 5 | 04-28-2002 09:08 AM |
| Knowing the shell, no using $SHELL variable | gloprest | Shell Programming and Scripting | 3 | 02-09-2002 08:05 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Shell variable with awk
line_no=6
echo 'Phone,' `awk 'NR==$line_no{print;exit}' <filename>` what is the error in this.. it says.. awk: Field $() is not correct. The input line number is 1. The file is <filename>. The source line number is 1. i want to print the data in the $line_no line of a certain file.. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
The error is improperly use of a shell variable. One way to use a shell variable with awk:
Code:
line_no=6
awk -v var=$line_no 'NR==var{print "Phone: "$0;exit}' <filename>
|
|
#3
|
|||
|
|||
|
thnks man.. it helped
|
|||
| Google The UNIX and Linux Forums |