bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbled print order


From: Andrew J. Schorr
Subject: Re: Garbled print order
Date: Tue, 13 Dec 2005 16:06:24 -0500
User-agent: Mutt/1.4.1i

On Tue, Dec 13, 2005 at 10:25:36PM +0200, Blayer-Gat Alon wrote:
> address@hidden:~]$ ipconfig | awk '$1 == "IP" {print
> $NF"suffix" }'
> suffix8.0.100
> 
> Not ok
> 
> address@hidden:~]$ ipconfig | awk '$1 == "IP" {print
> "prefix"$NF"suffix" }'
> suffix192.168.0.100
> 
> Not ok

I'll bet that $NF contains a trailing carriage return.  If you remove the
carriage return, I'll bet the problem does not occur.

For example:

   $ echo "hello\r" | gawk '{print $NF"goodbye"}'
   goodbye

And it is easily fixed using the sub() function:

   $ echo "hello\r" | gawk '{sub(/\r$/,""); print $NF"goodbye"}'
   hellogoodbye

Regards,
Andy




reply via email to

[Prev in Thread] Current Thread [Next in Thread]