![]() |
|
|
|
|
|||||||
| 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 |
| Variables | bobo | UNIX for Dummies Questions & Answers | 1 | 01-18-2007 10:37 PM |
| doing a sed on certain variables | seaten | UNIX for Dummies Questions & Answers | 10 | 09-05-2005 07:45 PM |
| doing a sed with variables | seaten | Shell Programming and Scripting | 1 | 05-06-2005 12:08 PM |
| doing a sed with variables | seaten | UNIX for Dummies Questions & Answers | 1 | 05-06-2005 11:48 AM |
| Using Variables to Set Other Variables | superdelic | UNIX for Dummies Questions & Answers | 3 | 04-21-2005 07:44 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Awk with variables
Hi
I have a file with a line like this, wich is read by an awk script : Logical Name | Server Type | Server1 | DB1 | User1 | $PASSWORD | Serv2 |DB2 | User2 | $PASSWORD Awk reads it fine, but...it doesnt interpret the variable $PASSWORD as I wish. How do I tell awk to substitute $PASSWORD by its value? Thanks a lot |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
... and what IS the value of '$PASSWORD'?
|
|
#3
|
|||
|
|||
|
This is the value:
echo $PASSWORD martinsc However, I dont want to use the value in the file. I need to use the variable $PASSWORD. Thank you. |
|
#4
|
||||
|
||||
|
something along these lines.....
nawk -v var='PASSWORD' -v val='foo' -f scar.awk myFile.txt scar.awk: Code:
BEGIN {
FS="|"
PAT_var= "(^| )[$]" var "($| )"
}
{
gsub(PAT_var, " " val " ")
print
}
|
||||
| Google The UNIX and Linux Forums |