ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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..
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.
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..
There is no need to use cat, awkandsed. The same can be done with a single awk or sed command:
Code:
sed -e "s/@@//g;s/@$//;s/.\{4\}$//" TT120T0-inbound # this does not remove the newlines, though
# I am not sure if that is what you want
# or
awk '{ gsub(/@@/,"",$0); sub(/@$/, "", $0); sub(/....$/,"",$0); printf $0 }' TT120T0-inbound
Also, the lines in your file are quite long. Some implementations of awk or sed might have a problem with that.
Quote:
Originally Posted by iffarrukh
Hi..
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.
Ok, then what is the difference between the binary and text versions?
the first one substitutes @@ with nothing, so it removes @@ from everywhere.
the second will remove the @ from the end of the lines
this two was taken from your original post
the third removes 4 characters from the end of the line.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.