Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP with replacing a particular field....

Status
Not open for further replies.

networkguy

Technical User
Jun 12, 2001
3
0
0
US
I'm trying to replace a specific field (field #12) in a string of fields separated by ;. The value for the field is the user input so basically it's a variable. The following is my script that doesn't seem to be working (OS=AIX 4.3.3):

#! /bin/ksh
read username?"Please enter your username:"
read password?"Please enter your password:"
awk 'BEGIN {FS=";";OFS=";"} { $12=$password;print }' input > output

If I were to replace $password with "text" it works just fine but as soon as it encounters a variable it fails. Is awk the way to go in this case? Would greatly appreciate any help!!!

Eric

 
#! /bin/ksh
read username?"Please enter your username:"
read password?"Please enter your password:"
nawk -v user=$username -v passwd=$password 'BEGIN {FS=";";OFS=";"} { $12=passwd;print }' input > output
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top