Re: RE: text manipulation with columns

From: DENNIS BYRNE <asdcb1@uaa.alaska.edu>
Date: Mon May 03 2004 - 09:11:46 AKDT

This works. I used the following.
cat hm9.txt | awk -F, '{print
$1","$2","$3","$4","$5","$6","$7","$8","$10","$9}'

Notice that $9 and $10 have been swapped. However, if I try to place a
hyphen after $9 ,

 cat hm9.txt | awk -F, '{print
$1","$2","$3","$4","$5","$6","$7","$8","$10","$9"\'"}'

the shell waits for more input. This happens with no or double
backslashes as well. What would the correct escape character be for
this?

Dennis Byrne

-- Attached file included as plaintext by Ecartis --

cat data.csv | awk -F, '{ print $1 ",-" $3 "-," $2 }'

Something like that?

the -F flag for awk sets the field separator to the next
character, instead of the default whitespace

> -----Original Message-----
> From: DENNIS BYRNE [mailto:asdcb1@uaa.alaska.edu]
> Sent: Monday, May 03, 2004 8:45 AM
> To: aklug@aklug.org
> Subject: text manipulation with columns
>
>
> Let's say I have a comma-delimited data set in a text file:
>
> a,67,12/12/1212
> b,8,1/1/1111
> v,-12,3/3/2004
>
> how do I manipulate the column order so I can get:
>
> a,12/12/1212,67
> b,1/1/1111,8
> v,3/3/2004,-12
>
> Furthermore, what would be a good way to wrap each date field with
> hyphens?
>
> Dennis Byrne
>
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Mon May 3 09:10:00 2004

This archive was generated by hypermail 2.1.8 : Mon May 03 2004 - 09:10:02 AKDT