Sponsored Content
Full Discussion: Masking of number
Homework and Emergencies Emergency UNIX and Linux Support Masking of number Post 302390193 by mad_man12 on Wednesday 27th of January 2010 06:40:15 AM
Old 01-27-2010
Masking of number

Code:
 
BAT:0310:2009-08-0:Y4   :H:D:00003721:03103721.IFH:00138770:05767:00000000001279'
EXR:CLP:912.570000'
STA:A:9071559:2009-08-10::Wer::Mrs'
DEF::531.97:531.97:310221661617::+ABC:BAL:1:N::::5:40.00:0.00:2009-08-10:CN:1111111111109962::3:N:missc :N:PH:00010833:
0001+ABC:FPT:4:N::::5:19.99:0.00:2009-08-10:CN:1111 1111 1111 9621::3:N:miss c ross:N:AI:00220600:S3IA'
VDI:2004-03-12:133030431725:4:M:00001912:AT:BSP:9124029676:2004-05-06:Parker:4:12:::::I:::::N::129.00:129.00
:1234567887234567678:0:155.40::6:::::+TAX:UB:6.30+TAX:XT:15.10'
CTR:2009-08-10:0.00:0.00:30.00:30.00:7819.00:7819.00'
GTR:11.50:0.00:0.00:28457.81:149449.38:21298.48:154882.82:1725.89'
TRA'

I have a txt file as above and i need to mask the middle digits of the credit card num such that only the first 6
and last 4 are visible.
The credit card number appear in 12th position in +ABC segment separted by :
( the 12th position can have other things also apart from the credit card which shouldn't be masked) the way to
identify credit card num is the field before it that is the 11 field in ABC section is having any of these values
TXE,AF,XT,TT,IT,TX,DX,TY,DT,MO,SE,CF,AXE,DF,CX,TF,DE,XF,CNE,IX,CN,SC,XTE,AX,CX
then credit card is in 12th position and needs to masked
The credit card can be of varying digits (16, 17, 19.........) and they can digits of credit card can appear
together or with space

The credit card number also appear in 26th position in VDI segment separated by :



I got quite a handful solution in the Unix forum but not exactly what i required the code was as below

Code:
awk -F'\+ABC' '{print$1}NF>1{for (i=2;i<=NF;i++)print $i}' OFS=':' |
awk -F: '{if ($27)print $27; else if ($12 ~ /^TXE$|^AF$|^XT$|^TT$|^IT$|^TX$|^DX$|^TY$|^DT$|^MO$|^SE$|^CF$|^AXE$|^DF$|^CX$|^TF$|^DE$|^XF$|^CNE$|^IX$|^CN$|^SC$|^XTE$|^AX$|^CX$/) print $13}' |
awk -F "" '{j=0; for(i=1;i<7+j;i++)if($i==" ")j++; for(;i<=(NF-4);i++)$i="*"}1' OFS=""



i am looking for the replacement in the input file itself such that
the script once run should replace with * in the input file, the above code is giving me separate output and only the masked card number only,

i need the whole file as output with only the cc num being masked.

please advice
Thanks in Advance!!
 

10 More Discussions You Might Find Interesting

1. IP Networking

IP Masking

Is it possible for a internal LAN to mask a IP e.g. i have a server ip running the intranet ip being 192.168.0.8 and i want to make that like www.intranet.com is this possible on a internal network ? (1 Reply)
Discussion started by: perleo
1 Replies

2. Shell Programming and Scripting

Masking Content of a String

Hello, I need to know that whether a content of a string can be hidden or masked inside a shell script. My Sample Code is given below <Code> #!/usr/bin/ksh Userid=test DB=temp Passwd=`java Decryption test` # The Above command will get the encryped password for "test" user id and store... (2 Replies)
Discussion started by: maxmave
2 Replies

3. Shell Programming and Scripting

Data Masking

I have a pipe delimited file that I need to 'mask' to before loading to keep some data confidential. I need to maintain the first 4 bytes of certain columns and replace the remaining bytes with an 'x'. I would like to maintain spaces but it's not a requirement. Example, need to mask columns 2... (2 Replies)
Discussion started by: 1superdork
2 Replies

4. Shell Programming and Scripting

masking issue

Hi I am facing an issue with the below script which has the below line each field being separated with a tab. I need to mask the 8 and 7th field based on following conditions 1. 8th field is 16 in length and is numerics i will mask the middle 6 digits except the first 6 and last 4. input... (2 Replies)
Discussion started by: mad_man12
2 Replies

5. UNIX for Advanced & Expert Users

.htaccess redirect with masking

I am looking to forward the following with masking via my .htaccess file: www.mywebsite.com/origpage www.mywebsite.com/newpage I do not want to forward the entire site, just this one page with masking. Neither page has an extension. I am able to forward with .htaccess - but it does not mask the... (1 Reply)
Discussion started by: globalnerds
1 Replies

6. Programming

Masking Password with *'s

So I've been working on this for some time now and can't seem to find the solution that works for me. I'm working in C/Unix. Basically, I want to take a user input and output something different. For example, I want to take a password and output *'s. In another instance, I want to take inputed... (35 Replies)
Discussion started by: bigdrock44
35 Replies

7. Shell Programming and Scripting

Masking algorithm

I have a requirement of masking few specific fields in the UNIX file. The details are as following- File is fixed length file with each record of 250 charater length. 2 fields needs to be masked – the positions are 21:30 and 110:120 The character by character making needs to be done which... (5 Replies)
Discussion started by: n78298
5 Replies

8. UNIX for Dummies Questions & Answers

Masking data

How Can I mask one particular columns using some unix command? (4 Replies)
Discussion started by: dsa
4 Replies

9. Shell Programming and Scripting

Masking with gsub command

My file "test.dat" data as below Requirement is to mask(replace) all english characters with "X" EXCEPT first 7 characters of every line. my command awk '{gsub("]","X")}1' test.dat looks not working properly, Appreciate any suggestion... (6 Replies)
Discussion started by: JSKOBS
6 Replies

10. Shell Programming and Scripting

Masking Bank Account Number except last 4 digits in the file

Hello Unix Guru's, I need help in the masking Bank Account Number except last 4 digits in the file using either unix command or shell script. I'm greatly appreciate your help. File Name: Sample.txt 560|101012|4267||||||||520114025017|Balance_bank|06/30/2018||||151716.41|AUD... (13 Replies)
Discussion started by: Pradeep R
13 Replies
ppmtosixel(1)                                                 General Commands Manual                                                ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 06:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy