Re: file editing
From: pop (p_o_p_at_hotmail.com)
Date: 08/16/04
- Next message: Chris F.A. Johnson: "Re: "wc" command"
- Previous message: sangeetha: ""wc" command"
- In reply to: Joey: "file editing"
- Next in thread: Eric Pement: "Re: file editing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 16 Aug 2004 12:32:42 GMT
change last line to:
next}{print}' $IN_FILE
--
pop is Mark
Old age ain't no place for sissies.
--
"Joey" <veshee@hotmail.com> wrote in message
news:fd9ccebb.0408160227.d98b922@posting.google.com...
> Hi
>
> I am tryung to edit a file with fix length fields
>
> i want to edit only the line beginig with a 'P' os 'S'
> the other must stay the same
>
> This result should be output to another file
>
> This is my attempt, the editing works fine , but i can get to print
> the rest f the lines in the file unchanged
>
> -------------
> #!/usr/bin/sh
> SCRIPT_NAME='MWMC252_DEPERSON.sh'
> #
> IN_FILE=${1}
> OUT_FILE='OUTFILE.JOB'
> DISTRICT='AA1 '
> TOWN1='ANYTOWN '
> TOWN2='NEWTOWN '
> NAME1='MR A CUSTOMER '
> NAME2='MRS A DCD '
> #
> COUNT=`grep ^P $IN_FILE | wc -l` # counts number of premises
> print ${COUNT}
> #
> awk '/^P/ {
> rem1=NR % 2
> id=substr($0,1,1);
> sequence=substr($0,2,4);
> name=substr($0,6,33);
> house=substr($0,39,38);
> street=substr($0,77,4);
> cycle=substr($0,81,2);
> walk=substr($0,83,3);
> read=substr($0,86,63);
> filler=substr($0,149,42);
> period=substr($0,191,2);
> time=substr($0,193,2);
> if (rem1 == 0)
> {
> printf("%s%sMR A CUSTOMER %s%s%s%s%s%s%s%s\n",id,
> sequence, house, street, cycle, walk, read, filler, period, time);
> }
> else
> {
> printf("%s%sMRS A DCD %s%s%s%s%s%s%s%s\n",id,
> sequence, house, street, cycle, walk, read, filler, period, time);
> }
> }' $IN_FILE
> #
>
> -------------
> Thanks in advance
>
> Joey
- Next message: Chris F.A. Johnson: "Re: "wc" command"
- Previous message: sangeetha: ""wc" command"
- In reply to: Joey: "file editing"
- Next in thread: Eric Pement: "Re: file editing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|