![]() |
|
|
|
|
|||||||
| 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 |
| How to print a value in the variable using awk ? | jisha | Shell Programming and Scripting | 1 | 01-14-2008 03:45 AM |
| print variable in file using awk | kamel.seg | Shell Programming and Scripting | 3 | 01-03-2008 02:43 AM |
| use variable for sed print line | atchleykl | UNIX for Dummies Questions & Answers | 2 | 04-24-2007 09:44 AM |
| can awk print column using a variable ?? | jambesh | Shell Programming and Scripting | 36 | 09-26-2006 04:39 AM |
| print the name of variable | sun-guy | Shell Programming and Scripting | 1 | 08-06-2006 02:03 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
i read the variable ph from file and i wanna to print it in awk.
example ph=`cat tmpbatch` tail h.txt|grep "| |"|awk -F"|" '{ print "@unpdx.sql",$5 }'"$ph" i try this but it does not work |
| Forum Sponsor | ||
|
|
|
||||
|
try using the -v switch when passing variables into Awk
awk -v foo=$ph ...... Here is a link Using Shell Variables in Awk Last edited by google; 05-13-2004 at 04:52 AM. |
|
|||
|
i try it but it does not work it give me error
suppose "ph" is a variable were calculated before ph= bla bla bla and i have an input file as aaa|1234 bbb|6325 ccc|7454 aaa|5467 i wanna to print in out put file second field of the line that contian aaa and at the end of each line the value of the variable. so the output will be 1234 bla bla bla 5467 bla bla bla and thnx in advance |
|
|||
|
i try the folowing code "just for testing" i get the following error
operate >tail ACCL.txt|awk -v ph="bla bla bla" '{print $2, ph}' awk: syntax error near line 1 awk: bailing out near line 1 and does this work if i ph calculated by exprestion as ph = `cat file` |