Help with varying data


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with varying data
# 8  
Old 02-14-2012
Hi


The record contains special characters like .(dot) and with the script you have provided i see that the data is not appended with zeros
# 9  
Old 02-14-2012
What special characters are they, and do this lines start with 2343 or there characters before that?
# 10  
Old 02-14-2012
please find the actual record

1000100 10111110xxxxxxxxxxxx1170 10111116 10111110000000000000000000Y010690 14110114401000001410191461141114740467010690 4001 1014FEsY FPPd ResYEXrEM141101144010000 CHICK-FIL-E FC10114401 PRLEMDP FL 410170000 XS 141114740467 040000000000000006.00040000000000000006.00 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00000000000.00001Y1401900001911111 000000000000000.00M000000000000000.00 P0001 1014140190000191117011111004111600000000041040 M0141460740477401 000000000000000.00 1110176141044001E 10111119.141941.1400BKZKH1.YSYS10.9971401

We have 992 characters but wen i use the code i need to be appended with 8 zeros but this does not happen with the code suggested by you. Could you suggest me how to proceed on this ?
# 11  
Old 02-14-2012
Hello akshay, that record does not begin with 2343 and you specified it should only happen to those records... For padding of any record leave out the selective criterion:
Code:
awk '{$0=sprintf("%s%0" w-length "s", $0,x)}1' w=1000 infile

# 12  
Old 02-14-2012
hi

I am using the code as below :
Code:
awk '/^1000100/ {$0=sprintf("%s%0" w-length "s", $0,x)}1' w=1000 infile

BUt this is not wrkin. so am i misssing something ?

---------- Post updated at 06:41 AM ---------- Previous update was at 06:07 AM ----------

hi

I am using the code as below :
Code:
awk '/^1000100/ {$0=sprintf("%s%0" w-length "s", $0,x)}1' w=1000 infile

since i want only records starting with 1000100 to be appended
BUt this is not wrkin. so am i misssing something ?

Last edited by Franklin52; 02-15-2012 at 06:24 AM.. Reason: Please use code tags for code and data samples, thank you
# 13  
Old 02-14-2012
That record has 620 characters, not 992. What OS are you on and what isn't working/what output do you get?
# 14  
Old 02-14-2012
hi

I am using a HP solaris OS and my actual data is as below:

---------- Post updated at 10:38 PM ---------- Previous update was at 10:36 PM ----------

1000100 20111212xxxxxxxxxxxx2114 20111209 20111212000000000000000000Y061499 172001226991 11429101341714009292834061499 3001 1661Shoe Stores 172001226991 JLHNSTLN & MURPHY S LRLANDL FL 328270000 US 714009292834 840000000000000014.91840000000000000014.91 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00 000000000000000.00000000000.00001Y1401980001922177 000000000000000.00 000000000000000.00 P0001 1813140198000191211411121201310400000000289784 N 000000000000000.00 1110276621111822A 20111229.131941.1400BKZ7UZ.TYS10.1081138

Last edited by akshay01987; 02-14-2012 at 11:46 PM.. Reason: the sample data file is in next page
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge lines with varying characters

Hi, I have a large set of data (firewall logs) that I'm trying to summarize. I've been able to write a script to consolidate the ports, now am looking to conslidate even further, based on IP. Source Destination Type Port 192.168.5.108 192.168.11.12 TCP 1, 2, 3, 4, 5, 15 192.168.5.109... (6 Replies)
Discussion started by: umang2382
6 Replies

2. Shell Programming and Scripting

How to separate data with varying amounts of underscores?

All, I've searched and haven't found a solution for my particular issue. I have a file with lines of data that contain varying amounts of underscores imbedded. But all the strings have a final underscore and an interface name: dmk_hcn_dalian2.XXXX.XXX.XX.COM_Se0/0/0... (4 Replies)
Discussion started by: turk22
4 Replies

3. Shell Programming and Scripting

Paste files of varying lengths

I have three files of varying lengths and different number of columns. How can I paste all three with all columns aligned? File1 ---- 123 File2 ---- 234 345 678 File3 ---- 456 789 Output should look like: 123 234 456 345 789 (6 Replies)
Discussion started by: Un1xNewb1e
6 Replies

4. Shell Programming and Scripting

Insert varying length spaces between words

Hey all, Fist post, so be kind... I have written an expect script which logs into a terminal and gathers several screens of information. Unfortunately the log file gives me all the special escape and control characters from the terminal. I am hoping to use a combination of shell scripting, sed,... (1 Reply)
Discussion started by: mpacer
1 Replies

5. Shell Programming and Scripting

How to check the varying file size

How to know a file is of fixed file or not over a span of time Actually my requirement is to check the size of the file in a specific directory for 60 seconds, and if it remains the same then I have to move to some other directory.Else I have to stop the execution. Request you to guide me in... (4 Replies)
Discussion started by: av_vinay
4 Replies

6. Shell Programming and Scripting

substitution of varying digits

I had a requirement in which in need to pan(*) out digits except the first six visible, followed by six *, and rest visible of a variable(input) ex: Input - 123456789012345 Output - 123456******345 ex: Input - 1234567890123456 Output - 123456******3456 so i tried something like... (12 Replies)
Discussion started by: mad_man12
12 Replies

7. Shell Programming and Scripting

extract string from varying delimiter line

Hi I have lines like this a=1, b=2, c=3, a=1, d=4, e=5, b=225, I need to extract the b=nnn... value. I dont know how many other entries will be before and after it in each line. Ive tried a basic line like awk '/b=/, $NF ~ /,/ ' myfile.txt but I think that it doesnt care which comma it... (5 Replies)
Discussion started by: rebelbuttmunch
5 Replies

8. Shell Programming and Scripting

Varying number of awk search strings

I've created an awk script that handles a varying number of search strings handed to it as command line parameters ($1 $2 etc). There may be 1, or 2 or 3 or more. A simplified version of the script is: awk -v TYP="$1 $2 $3 $4 $5 $6" ' BEGIN { CTYP = split (TYP,TYPP," ") } ... (2 Replies)
Discussion started by: CarlosNC
2 Replies

9. Shell Programming and Scripting

Parse apart strings of comma separated data with varying number of fields

I have a situation where I am reading a text file line-by-line. Those lines of data contain comma separated fields of data. However, each line can vary in the number of fields it can contain. What I need to do is parse apart each line and write each field of data found (left to right) into a file.... (7 Replies)
Discussion started by: 2reperry
7 Replies

10. Shell Programming and Scripting

deleting a varying amount of lines from a list of files

I did search the posts for info on this and while there were some in the ballpark, none addressed this specifically. (also I tried to post this once it said I was logged out, so hopefully I'm not sending a duplicate here). I have a set of files (250 +/-) where I need to delete the first "$x"... (4 Replies)
Discussion started by: benair
4 Replies
Login or Register to Ask a Question