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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mask data when reading a file

Status
Not open for further replies.

bob0209

Programmer
Jun 15, 2006
2
GB
hi all,

quick question,

I want to change the data of a field while i am reading from a file. let me explain

sample file

ID Deptno Sal Name

123 A20 3000 Tom
234 D50 2900 Harry


when i am reading the file and reformatting the file i want the result to be


ID Deptno Sal Name

123 A20 3000 XXXXX
234 D50 2900 XXXXX

i tried this awk -F, '{$4 = "XXXXX"; print }' OFS=, but when the script is in the config file it is asking for a value for $, any other way of doing this.


Thanks in advance


 
Hi

bob0209 said:
when the script is in the config file
How could a script be in a config file ? The first is executable code, the second is static data.

Tell us abit more, or try escaping the dolar sign ( $ ) by puting a backslash ( \ ) in front of it.

Feherke.
 
The fact is we have to execute that statement in the config where we read a file and format the file and during that process we have to mask the name feild to XXXXX, we tried to put '/' in front of the $ but doesnt help it is still asking for values.

Thanks
 
Hi

bob0209 said:
it is still asking for values
Sorry, I still not understand it. Who is asking for values ?

When I asked for more detail, I thought to configuration file format ( maybe some sample too ) and the application which use it.

Feherke.
 
when i am reading the file and reformatting the file
How do you do that ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Try removing the "[tt]-OFS,[/tt]". Your input data isn't separated by commas.
 
Why not cut the file in two; edit the bit with $1 $2 $3 then join them back up again?

or

Stick some gaffer tape over that bit of the screen.

Mike

Unix *is* user friendly. It's just selective about who its friends are.
 
How about this:

Code:
awk '!/ID|^$/{print $1"  "$2"    "$3"    ""XXXXX"}' inputfile

Regards,
Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top