[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: printing columns into a file
From: |
Arnaldo Mandel |
Subject: |
RE: printing columns into a file |
Date: |
Wed, 30 Dec 2009 07:39:57 -0200 |
Jin wrote (on Dec 27, 2009):
> 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 on emacs but moves the value
> below upward to cover the blank. So, it'd be like
There are two solutions:
a) You slighly change the file format, introducing a column
separator. Tab would be convenient, since you can make it look
like a space in emacs. Then you can use that as a field separator
for awk or cut.
b) If you don't have a field separator, your columns are determined by
a range of positions in the line. You can figure them out and give
them as parameters to cut -c.
--
Arnaldo Mandel
Departamento de Ciência da Computação - Computer Science Department
Universidade de São Paulo, Bra[sz]il
am@ime.usp.br
Talvez você seja um Bright http://the-brights.net Maybe you are a Bright.