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

Notices

Reply
 
Search this Thread
Old 03-01-2007, 03:07 PM   #1
korhan
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

man%boy%girl
joe%jack%johnny

to
man
boy
girl

joe
jack
johnny

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
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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
korhan
LQ Newbie
 
Registered: Feb 2007
Posts: 2

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

solved!

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


Reply


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


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

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