Masking off data for different kind of files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Masking off data for different kind of files
# 1  
Old 06-02-2011
Masking off data for different kind of files

Hi everyone,
I am required to mask off the date data for 3 kinds of files. Please help me to find a most generic way to handle the files. Example of the content of each kind(the dates are in red):
1. (1-line files). Possible solution: Date needed to be masked off start with DTM+, end with :203
Code:
DTM+7:201103281411:203'LOC+175+SGSIN:139:6+TERMINATOR......'DTM+132:201103281413:203'LOC....

2.(line by line files). Possible solution: Date needed to be masked off in position 5 to 12 of each line
Code:
EXIT201103281044IAAU 3680272 4363400018000DD                 FIL  IL  LEA PERDANA      006     006         MANLEE   FD LD RD DD                    N
 
DISC201103281101TCKU 9672645 45G1400022500DD                 FIL  RC      VIRO BHUM        S079    S079                                             0300312TCNTXG                     NN N

3.(1 line). Possible solution: Break the line for every 400 character , find the line starting with HHDR, then mask the date from position 14-21
Code:
HHDR   01010020110208000004NYK VERANICD     266                                                    2011020704100020110207181500                                                                                                                                                                                                                                                                                 D              NYKU 5629211                                                                                              F22521  NY   NY      N                                                                                                                          N                                                 NZLYT             NZZ063854            4510LCI                                       C                                                                                                                                                                                                                                                                                                                                                                                                               HHDR   01010020110208000004ARUNIRICKMER     008W                                                   2011020717050020110208010000

Comparing to my solutions above, anyone have a more generic way to handle these 3 kind of files?
Thanks for any effort.

---------- Post updated at 10:48 AM ---------- Previous update was at 10:43 AM ----------

E.g Code to mask off the date(for file 1):
nawk'{gsub(/DTM\+7[^>]*'"'"'203/, "DTM+7:201'"'"'203")}'
# 2  
Old 06-03-2011
1.(1-line files):
Code:
awk -F: '/DTM+/{print $2}' file

2.(line by line files):
Code:
awk '{print substr(5,8)}' file

3.(1 line):
Code:
awk -F"HHDR" '{for(i=2;i<=NF;i++)print substr($i,10,8)}' file

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In PErl script: need to read the data one file and generate multiple files based on the data

We have the data looks like below in a log file. I want to generat files based on the string between two hash(#) symbol like below Source: #ext1#test1.tale2 drop #ext1#test11.tale21 drop #ext1#test123.tale21 drop #ext2#test1.tale21 drop #ext2#test12.tale21 drop #ext3#test11.tale21 drop... (5 Replies)
Discussion started by: Sanjeev G
5 Replies

2. 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

3. Shell Programming and Scripting

Combine data from two files base on uniq data

File 1 ID Name Po1 Po2 DD134 DD134_4A_1 NN-1 L_0_1 DD134 DD134_4B_1 NN-2 L_1_1 DD134 DD134_4C_1 NN-3 L_2_1 DD142 DD142_4A_1 NN-1 L_0_1 DD142 DD142_4B_1 NN-2 L_1_1 DD142 DD142_4C_1 NN-3 L_2_1 DD142 DD142_3A_1 NN-41 L_3_1 DD142 DD142_3A_1 NN-42 L_3_2 File 2 ( Combination of... (1 Reply)
Discussion started by: pareshkp
1 Replies

4. Shell Programming and Scripting

Masking data for different file format

Hi, I have 3 kind of files that contains date data needed to be masked. The file is like this: File 1 (all contents in 1 line): input:DTM+7:201103281411:203'LOC+175+SGSIN:139:6+TERMINATOR......'DTM+132:201103281413:203'LOC.... output:... (4 Replies)
Discussion started by: Alvin123
4 Replies

5. 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

6. 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

7. 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

8. UNIX for Dummies Questions & Answers

is there kind of good utility that convert make files to dsp?

Hello all im looking for some kind of utility that convert make files to dsp files is there any kind of tool/script that does this job? thanks (1 Reply)
Discussion started by: umen
1 Replies

9. 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
Login or Register to Ask a Question