Computing.Net > Forums > Unix > filping rows to column

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

filping rows to column

Reply to Message Icon

Name: gpatel
Date: September 13, 2006 at 08:30:28 Pacific
OS: UNIX
CPU/Ram: 512
Product: SUN
Comment:

All,
I have this little nawk script that grab the information i need from a file. here is what my problem is
file = 1 1 red
2 3 red
4 5 red
using nawak to get all the red
nwak '/red/{print$1,$2}' file
output = 1 1
2 3
4 5

NOW if i do this

set red_data = `nwak '/red/{print$1,$2}' file`

$echo red_data
i get this
1 1 2 3 4 5

i want to change this variable in to look like this
1 2
2 3
4 5
so echo $red_data should look like that.
thanks a lot for your help.

~gpatel



Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: September 14, 2006 at 07:48:14 Pacific
Reply:

Your variable is fine as is, but the nature of echo is to eliminate the line breaks.

Double-quotes will keep them, at least on linux.

echo $red_data
1 1 2 3 4 5

echo "$red_data"
1 1
2 3
4 5


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: filping rows to column

displaying words in a row to column www.computing.net/answers/unix/displaying-words-in-a-row-to-column/4945.html

convert text rows to columns awk www.computing.net/answers/unix/convert-text-rows-to-columns-awk-/7374.html

help w/ script grep row and column www.computing.net/answers/unix/help-w-script-grep-row-and-column/6957.html