mask ID number


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mask ID number
# 1  
Old 07-20-2007
mask ID number

HP-UX 11i v2. #!/bin/sh

Hi all.

I have a flat file like this with lines like this:

|07/19/07|08:26AM|1|CupsCoffee|CupsCo|989898989 |Doe, John Y |THE PLUS CARD - Price| | |Y| | 2.00|

I would like to replace the id number (field 6) with a masked version, ie *****8989. Everything else stays the same. The field is always 9 characters. I was thinking about sed or maybe tr.

Thanks in advance!!!!
# 2  
Old 07-20-2007
Try:
awk -v 'FS=|' -v 'OFS=|' '{ $7="*****"substr($7,6,4) ; print $0 }' data
# 3  
Old 07-20-2007
Perderabo,

Perfect!

Thanks!!!!!
# 4  
Old 07-20-2007
Based on your data sample:
Code:
sed 's/|...../|*****/5' input_file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep match a mask

Hi all, Im trying to use grep to match a exact mask where some characters are known and some are not. for example: j***n@email.com in this case the length is known and the position of the unknown characters are know (and will be ) any idea how I can do this? the file list is not just... (3 Replies)
Discussion started by: flamer
3 Replies

2. UNIX for Dummies Questions & Answers

What is mask and effective right mask in setfacl?

Hi Guys, can someone explain what is mask and effective right mask in setfacl and getfacl command with example, unable to get it. (3 Replies)
Discussion started by: Jcpratap
3 Replies

3. Red Hat

Samba create mask and dir mask on RHEL 4.8

Hi Experts, I'm using samba -3.6.1 on Red Hat Enterprise Linux ES release 4 (Nahant Update 8) ,all seems ok. The issue im facing is as follows. When ever a user creates a file via windows explorer the permissions assgined to the file are as follows -rw-rwxr--+ 1 tom group2 0 Mar 9... (1 Reply)
Discussion started by: maverick_here
1 Replies

4. UNIX for Dummies Questions & Answers

how to mask the password ?

Hi All, i am executing peoplesoft sqr command from unix prompt which has the unix id/password as parameter along with other parameters. i want to show whole command in log file but want to mask the id/password field. this command i am executing in shell script. Please suggest.. >sqr sqrname... (2 Replies)
Discussion started by: avi.coep
2 Replies

5. Shell Programming and Scripting

Need to Mask Data

I have an requirement. There is a file which has the below contents Unix|123|17-01-2010 .... .... .... .... and so an now each letter has a corresponding predefined mapping letter in order to mask the original data.(for example U = A, n=b, i=c, x=d, same like number 1=9,2=8,3=7. Also... (8 Replies)
Discussion started by: ksmbabu
8 Replies

6. Solaris

Need help in changing the subnet mask

Hi, I have a task to edit the subnet mask in almost 100+ solaris servers.Few of the servers are configured with IPMP.There will be no change of IP address or default gateway.If its a single IP we can bring NIC down,change the subnet mask in /etc/netmasks,then bring the NIC back to normal.But... (3 Replies)
Discussion started by: rajip23
3 Replies

7. Shell Programming and Scripting

umask : improper mask

Dear Guru, I see the result after I run the script as below I don't know what does it mean so please explain to me. Thanl in advance (2 Replies)
Discussion started by: unitipon
2 Replies

8. IP Networking

Changing the mask

What is the command to change the mask to 255.255.255.0 The system was set up incorectly and the mask needs to be corrected (1 Reply)
Discussion started by: kkinnon
1 Replies

9. Programming

password mask in C

Hi, Could any one help me to write a C program for password mask with ******. I mean whatever word i will type that will show on the screen as ***** and should store the correct value in a variable. Thanks in advance Krishna (5 Replies)
Discussion started by: krishna
5 Replies

10. IP Networking

Subnet mask

Hi, I have about 30 computers for users with subnet mask x.x.x.0, and 25 computers for workers with s.m. x.x.x.128. My server has a s.m. x.x.x.128 so with workers computers I can see my server and all the computers in that s.m., but I can't see the server from the users computers and I need to see... (7 Replies)
Discussion started by: Z0DiaC
7 Replies
Login or Register to Ask a Question