RedHat iTOps Tube

Monday, May 14, 2012

substring using awk and sed ( binary )

Hi..

I got a problem and I am looking some help. I was using this command to remove @ from binary file and then getting substr and finally using printf formating it and putting into a file. I am trying to run this using new version of awk(3.1.7) and I am just getting 4 character while previously I was almost 8727( awk 3.1.3)

I know awk is not supposed to work with binaries but code is written year ago and I cannot change a lot..



$ cat TT120T0-inbound | sed -e "s/@@//g;s/@$//" | awk ' begin {} {x = substr($0,1,length($0) - 4); printf("%s", x); }' >> Final-data



Any help..



I have attached the data as well but its a txt file not binary file so might not work properly . but just for reference. Have a look at snapshot as well.



Thanks in advance





Regards

Sam













Attached Images





File Type: jpg snapshot.jpg (44.1 KB)






Attached Files





File Type: txt binary.txt (9.2 KB)