[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Garbled print order
From: |
John.Cowan |
Subject: |
Re: Garbled print order |
Date: |
Tue, 13 Dec 2005 15:54:07 -0500 |
User-agent: |
Mutt/1.4.2.1i |
Blayer-Gat Alon scripsit:
> address@hidden:~]$ ipconfig | awk '$1 == "IP" {print
> $NF"suffix" }'
> suffix8.0.100
This is not a gawk bug. (I got suspicious when I saw that mawk failed
in the same way.) Despite appearances, the actual output is
10.90.0.159\r\rsuffix\n
This arises because "ipconfig" is a native Windows utility and outputs
\r\n at the end of each line. Cygwin assumes that text read from a
pipe has proper \n terminators, and therefore the \r at the end of each
line is not stripped and is treated by awk as part of the last field.
(I'm not quite clear why there are two of them.)
The following approach will work:
$ ipconfig | dos2unix | awk '$1 == "IP" {print $NF"suffix" }'
10.90.0.159suffix
--
What is the sound of Perl? Is it not the John Cowan
sound of a [Ww]all that people have stopped address@hidden
banging their head against? --Larry http://www.ccil.org/~cowan