The UNIX and Linux Forums  

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
Replace string in a file w/ a variable value tret Shell Programming and Scripting 5 12-08-2008 07:38 PM
numeric string and length dragrid Shell Programming and Scripting 1 12-08-2008 12:15 PM
Replace spaces with 0's having numeric values. videsh77 Shell Programming and Scripting 1 04-15-2005 02:22 AM
creating a fixed length output from a variable length input r1500 Shell Programming and Scripting 2 12-03-2003 01:09 PM
Finding out the length of a string held within a variable dbrundrett Shell Programming and Scripting 5 02-19-2002 08:02 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-06-2009
mk4mzid mk4mzid is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 3
Replace variable length numeric string

I have a customer who logged some cc and bank account numbers in their apache logs. I got the cc numbers x'd out with
Code:
sed -e 's/args=[0-9]\{16\}/args=XXXXXXXXXXXXXXXX/g' -e 's/cardnum=[0-9]\{16\}/cardnum=XXXXXXXXXXXXXXXX/g'
but that wasn't too difficult due to the value being 16 digits.

The bank account info is different, might be 6 digits, might be 10, might be 15. The actual string in the log entry will contain
Code:
args=123456789&acctnum=123456789
somewhere in the middle of the line.

Now that I think about it, the new value doesn't have to match the original, meaning if it's a 7 digit value, I don't have to have 7 x's, I can replace the value, whatever the length, with say 7 or 10 x's. I'm just not sure how to identify the original variable length string.

Any thoughts?
 

Bookmarks

Tags
replace, sed, variable length strings

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 01:26 PM.


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