Re: change character ordering within a record
From: Robert Bonomi (bonomi_at_host122.r-bonomi.com)
Date: 07/26/05
- Next message: John W. Krahn: "Re: change character ordering within a record"
- Previous message: Ted Timar: "Welcome to comp.unix.shell [Frequent posting]"
- In reply to: kanpeter_at_graduate.hku.hk: "change character ordering within a record"
- Next in thread: John W. Krahn: "Re: change character ordering within a record"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 26 Jul 2005 05:06:33 -0000
In article <1122351043.229874.190260@z14g2000cwz.googlegroups.com>,
<kanpeter@graduate.hku.hk> wrote:
>Hi all,
>
>How can I change the character ordering, say to move the 4th-6th
>characters to 2nd-4th positions and move the 2nd-3rd characters to
>5th-6th positions within a record which may contain space character?
>
>('123456 90' -> '145623 90')
>
>
>Peter
>
when you have an 'awkward' problem, awk(1) is usually the answer.
use the substr function on $0 to extract the particular character
sequences, and printf to output the re-ordered line.
- Next message: John W. Krahn: "Re: change character ordering within a record"
- Previous message: Ted Timar: "Welcome to comp.unix.shell [Frequent posting]"
- In reply to: kanpeter_at_graduate.hku.hk: "change character ordering within a record"
- Next in thread: John W. Krahn: "Re: change character ordering within a record"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|