home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!cs.utexas.edu!torn!cunews!nrcnet0!bnrgate!bcars267!bcarh803!christo
- From: christo@bcarh803.BNR.CA (Mark Christopher)
- Subject: Re: awk with columns
- Message-ID: <1992Sep3.222416.12370@bnr.ca>
- Sender: news@bnr.ca (usenet)
- Nntp-Posting-Host: bcarh803
- Reply-To: christo@bnr.ca
- Organization: Bell-Northern Research Ltd.
- References: <29098@hydra.Helsinki.FI>
- Date: Thu, 3 Sep 1992 22:24:16 GMT
- Lines: 28
-
- In article <29098@hydra.Helsinki.FI>, karell@cs.Helsinki.FI (Esa Karell)
- writes:
- |>Could someone tell me what would be the easisest
- |>way to accomplish this with awk.
-
- |>X Y T P I
- |>1 2 3 4 5
-
- |>I'd need to swap the values of Y & T so output should look:
- |>
- |>X Y T P I
- |>1 3 2 4 5
- |>. . . . .
- |>
- |>All the blanks between the columns should remain the same.
-
- Well, what do you think? Two easy ways:
-
- Come up with a printf format string and say
-
- { printf "....format....",$1,$3,$2,$4,$5 }
-
- or else find the column numbers and do:
-
- { print substr(..),substr(..),... }
-
- --
- Mark Christopher Bell-Northern Research christo@bnr.ca
-