Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 03-01-2007, 03:07 PM   #1
LQ Newbie
Registered: Feb 2007
Posts: 2

Rep: Reputation: 0
AWK - why fields go to seperate lines?

Doing a homework and when i write this every field goes different lines in the output? How can i fix it?

awk -F"%" '{ for (i=1; i< $3; i++){ print $i }}' text.txt




i want:

man boy girl
joe jack johnny

i left 3 hours please be quick

Last edited by korhan; 03-01-2007 at 03:09 PM.
Old 03-01-2007, 03:16 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I don't do homework for others, but I will point out that the default behavior of print is to append a newline. On the other hand, printf() does not.
--- rod.
Old 03-01-2007, 03:21 PM   #3
LQ Newbie
Registered: Feb 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks very much!!


By the way: it is the smallest part of hw
and i spent 2 hours for adding "f" to print


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
awk to remove first 3 lines and print remaining $1, $2 fields phyx Linux - General 1 01-10-2007 05:21 PM
How to use awk command to parse fields in a line johnsanty Programming 9 05-25-2006 09:56 PM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM
Supressing Fields w/ AWK Rv5 Programming 3 10-19-2004 11:06 AM
search for specific text in fields using awk Helene Programming 2 04-23-2004 12:13 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration