LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   AWK - why fields go to seperate lines? (https://www.linuxquestions.org/questions/linux-newbie-8/awk-why-fields-go-to-seperate-lines-533674/)

korhan 03-01-2007 03:07 PM

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 :)

theNbomr 03-01-2007 03:16 PM

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.

korhan 03-01-2007 03:21 PM

Thanks very much!!

solved!

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


All times are GMT -5. The time now is 06:33 PM.