dcsimg
Linux Today: Linux News On Internet Time.





More on LinuxToday


Intro to Awk, the Great Language with a Strange Name

Jul 16, 2008, 06:30 (0 Talkback[s])
(Other stories by Daniel Robbins)

WEBINAR:
On-Demand

How to Help Your Business Become an AI Early Adopter


[ Thanks to LinucksGirl for this link. ]

"As you can see, awk prints out the first and third fields of the /etc/passwd file, which happen to be the username and uid fields respectively. Now, while the script did work, it's not perfect -- there aren't any spaces between the two output fields! If you're used to programming in bash or python, you may have expected the print $1 $3 command to insert a space between the two fields. However, when two strings appear next to each other in an awk program, awk concatenates them without adding an intermediate space. The following command will insert a space between both fields:"

Complete Story

Related Stories: