The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Mask ur MAC address in BSD PenguinDevil BSD 1 06-12-2004 10:43 PM
How do I mask my MAC address PenguinDevil IP Networking 2 04-26-2004 02:26 PM
Changing the mask kkinnon IP Networking 1 04-02-2003 12:05 PM
password mask in C krishna High Level Programming 5 06-18-2002 08:31 AM
Subnet mask Z0DiaC IP Networking 7 09-15-2001 07:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-20-2007
lyoncc lyoncc is offline
Registered User
  
 

Join Date: May 2007
Posts: 21
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 (permalink)  
Old 07-20-2007
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Try:
awk -v 'FS=|' -v 'OFS=|' '{ $7="*****"substr($7,6,4) ; print $0 }' data
  #3 (permalink)  
Old 07-20-2007
lyoncc lyoncc is offline
Registered User
  
 

Join Date: May 2007
Posts: 21
Perderabo,

Perfect!

Thanks!!!!!
  #4 (permalink)  
Old 07-20-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Based on your data sample:
Code:
sed 's/|...../|*****/5' input_file
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0