Home > Archive > AWK > November 2004 > Trimming the first line of a file.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Trimming the first line of a file.
|
|
| Rob Bradford 2004-11-17, 8:55 pm |
| All.
I have used AWK a little and know it can do this but I can't work out
how, so I'm hopimg someone here can point me in the right direction.
I have a file beinf FTP'd from a MPE/XL (HP3000) system, yes we still
have one, but the MPE variant of FTP pads all lines to the same
length! (it's in the manual that it will do this in ASCII mode).
Using Binary or Bytestream modes yeild worse results for our purpose.
My problem is this the file I have has a header line of 46 characters
followed by n lines of 1468 characters, when I get the file delivered
onto a HP-UX system all teh lines are1468 characters then a line-feed.
Can AWK process the first line back to 46 chatracters and not touch
the body of the file?
Any help or pointers would be appreciated.
| |
| Chris F.A. Johnson 2004-11-17, 8:55 pm |
| On Wed, 17 Nov 2004 at 21:36 GMT, Rob Bradford wrote:
> All.
>
> I have used AWK a little and know it can do this but I can't work out
> how, so I'm hopimg someone here can point me in the right direction.
>
> I have a file beinf FTP'd from a MPE/XL (HP3000) system, yes we still
> have one, but the MPE variant of FTP pads all lines to the same
> length! (it's in the manual that it will do this in ASCII mode).
> Using Binary or Bytestream modes yeild worse results for our purpose.
>
> My problem is this the file I have has a header line of 46 characters
> followed by n lines of 1468 characters, when I get the file delivered
> onto a HP-UX system all teh lines are1468 characters then a line-feed.
>
> Can AWK process the first line back to 46 chatracters and not touch
> the body of the file?
awk 'NR == 1 { $0 = substr($0,1,46) }
{ print }'
|
|
|
|
|