Home > Archive > AWK > January 2008 > Line truncation.
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]
|
|
| Rob Bradford 2008-01-23, 7:01 pm |
| Hi.
I have a issue with a file from an old legacy (HP3000) system. When the file
is transfered by FTP onto a Unix server the 3000's FTP process pads the
lines to a fixed length. This seems to be a function of the 3000's FTP
implementation. ie: It picks up a fo;e of say 1674012 bytes and sends
1709094 bytes for example!
Anyway to cut a long story short, how do I chop each and every line back to
the last no white_space character? Each of the extended lines has a LF that
I need to keep, or replace it in the new end-of line opsition. I know AWK
should be the solution but where do I start?
Any pointers would be appreciated.
Rob.B
--
(\__/) This is Bunny.
(='.'=) Help him and his friends by supporting the
(")_(") Rabbit Welfare Association: www.houserabbit.co.uk
| |
| Kees Nuyt 2008-01-23, 7:01 pm |
| On Wed, 23 Jan 2008 18:58:03 -0000, "Rob Bradford"
<rob.polymnia@btinternet.com> wrote:
>Hi.
>
>
>I have a issue with a file from an old legacy (HP3000) system. When the file
>is transfered by FTP onto a Unix server the 3000's FTP process pads the
>lines to a fixed length. This seems to be a function of the 3000's FTP
>implementation. ie: It picks up a fo;e of say 1674012 bytes and sends
>1709094 bytes for example!
>
>Anyway to cut a long story short, how do I chop each and every line back to
>the last no white_space character? Each of the extended lines has a LF that
>I need to keep, or replace it in the new end-of line opsition. I know AWK
>should be the solution but where do I start?
>
>Any pointers would be appreciated.
>
>Rob.B
{
sub(/[[:blank:]]+$/,"")
print
}
--
( Kees
)
c[_] When a screen is called a desktop, a picture on it
should be called table cloth, not wallpaper. (geof) (#224)
| |
| Ed Morton 2008-01-23, 7:01 pm |
| On 1/23/2008 12:58 PM, Rob Bradford wrote:
> Hi.
>
>
> I have a issue with a file from an old legacy (HP3000) system. When the file
> is transfered by FTP onto a Unix server the 3000's FTP process pads the
> lines to a fixed length. This seems to be a function of the 3000's FTP
> implementation. ie: It picks up a fo;e of say 1674012 bytes and sends
> 1709094 bytes for example!
>
> Anyway to cut a long story short, how do I chop each and every line back to
> the last no white_space character? Each of the extended lines has a LF that
> I need to keep, or replace it in the new end-of line opsition. I know AWK
> should be the solution but where do I start?
>
> Any pointers would be appreciated.
awk 'sub(/[[:blank:]]+$/,"")1' file
but, since you're on UNIX, there's a better solution. Post to comp.unix.shell if
interested.
Ed.
| |
| William James 2008-01-24, 8:00 am |
| On Jan 23, 12:58 pm, "Rob Bradford" <rob.polym...@btinternet.com>
wrote:
> Hi.
>
> I have a issue with a file from an old legacy (HP3000) system. When the file
> is transfered by FTP onto a Unix server the 3000's FTP process pads the
> lines to a fixed length. This seems to be a function of the 3000's FTP
> implementation. ie: It picks up a fo;e of say 1674012 bytes and sends
> 1709094 bytes for example!
>
> Anyway to cut a long story short, how do I chop each and every line back to
> the last no white_space character? Each of the extended lines has a LF that
> I need to keep, or replace it in the new end-of line opsition. I know AWK
> should be the solution but where do I start?
>
> Any pointers would be appreciated.
>
> Rob.B
>
> --
> (\__/) This is Bunny.
> (='.'=) Help him and his friends by supporting the
> (")_(") Rabbit Welfare Association:www.houserabbit.co.uk
mawk 'BEGIN{RS=" *\n"}8' the_file
awk 'BEGIN{FS=" +$"}{print $1}'
|
|
|
|
|