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.
Side question here. I've seen this final "1" used on the end of an awk expression a few times now, and ran a few tests that tell me it makes awk print out every line, modified or not. But I've yet to track down any documentation that explains what it's doing. Could you fill me in a bit here?
That being one of the guilty parties I was referring to ...
Quote:
(what happens if more than 2 fields .... ????)
Well... nothing special. All the fields but the first one are removed from the first 4 lines. Trying to remove only the last field brings to more complicate expressions (and bad programming, too).
Side question here. I've seen this final "1" used on the end of an awk expression a few times now, and ran a few tests that tell me it makes awk print out every line, modified or not. But I've yet to track down any documentation that explains what it's doing. Could you fill me in a bit here?
You have to take in mind two things:
1) In awk TRUE is represented by a non-null string or a numeric value other than 0, FALSE is the null-string or 0.
2) An awk rule is made of
Code:
pattern { action }
when the action is not specified, the default one is applied (that is print $0).
Said that the following are very simple programs that evaluates the pattern as TRUE and apply the default action:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.