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.
'{printf "%s", $0}! - print each string %s from each line;
(NR % 8){printf "\n"}' set the Number of Rows as 8 then put \n [ENTER]
Is this make sense ?
Not really. The statement
Code:
{printf "%s", $0}
prints out the whole line (record in awk) without the newline at the end. The expression
Code:
!(NR % 8)
negates (!) the remainder of the division between the current record number (NR) and 8. Take in mind that in awk any numeric value different from zero or any string different from the null string is evaluated as true. We need to print a newline whereas the remainder is 0 (that is every 8 records) so that the expression must be evaluated as true when it is 0, as false for any other value. This is the opposite of what awk does, hence the negation.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.