Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

printing columns into a file

0 views
Skip to first unread message

Sally

unread,
Dec 27, 2009, 9:45:14 PM12/27/09
to
Hi,

I will really appreciate any help on this!

I have a file looking like the following

date month year

12 5 1982
30 6 1982
3 1982
28 1877
30 2 1888

As you can see, my file has blanks in a column, but I like to keep it
that way.
When I tried to use awk to print each column into a separate file
(date.txt, month.txt, and year.txt),
it doesn't retain the blank information but moves the value below
upward to cover the blank. So, it'd be like

date.txt
12
30
28
30

month.txt
5
6
3
2

How can I keep the blank as it is in the original fiile?

Please help.

Grant

unread,
Dec 27, 2009, 10:50:26 PM12/27/09
to

This may get you started, needs more work:

~$ gawk 'BEGIN {FIELDWIDTHS = "12 12 12"}; {print $1 > "date.txt";print $2 > "month.txt";print $3 > "year.txt"}' datafile

Grant.
--
http://bugsplatter.id.au

Sally

unread,
Dec 27, 2009, 10:57:51 PM12/27/09
to
On Dec 27, 9:50 pm, Grant <g_r_a_n...@bugsplatter.id.au> wrote:

I'll try.
Thanks.

0 new messages