Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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 experts,
I have a text file consisting five columns (tab separated). The first column is a timestamp; the other columns have values between +4000.0 and -4000.0 .I like to remove all the lines, which apart from the timestamp, have only "0" values.
Do you have any suggestion how to do this easily (awk or sed)?
It returns the correct values but only in a positive range. When I try to filter for negative values ( eg. $2 < 0) it returns everything including "0" values.
There must be a way to exclude the zeros.
The two lines in shaded brown (containing only zeroes) are removed from the output. Moreover, notice that you might omit the FS specification since TAB is one of the default separators in awk. From the GNU awk user's guide:
Quote:
By default, fields are separated by whitespace, like words in a line. Whitespace in awk means any string of one or more spaces, TABs, or newlines;
...
In POSIX awk, newlines are not considered whitespace for separating fields.
All of them return what I was looking for. I will check tomorrow on a Solaris 8 machine.
The 3rd piece of code makes sense to me but for the other two it's not clear for me why I get this result, -
and why my first attempt
I've checked different syntaxes which is working on openSUSE on a solaris8 machine and none of them are working. They return an error message:
awk: syntax error near line 1
awk: bailing out near line 1
I've checked the
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.