delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/11/07:44:35

Date: Sun, 11 Jan 1998 14:44:26 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Weiqi Gao <weiqigao AT a DOT crl DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: DJGPP gawk peculiarity
In-Reply-To: <34B6D45A.8A0733FB@a.crl.com>
Message-ID: <Pine.SUN.3.91.980111144409.15603Z-100000@is>
MIME-Version: 1.0

On Fri, 9 Jan 1998, Weiqi Gao wrote:

> ======================================================================
> C:\TEMP> cat junk
> 123 456
> 
> C:\> awk 'length($1) < 2 {print $1}' junk
> 123
> ======================================================================
> 
> What am I missing here?

Did you actually run this from the DOS prompt?  If so, which shell did
you use?  COMMAND.COM won't let Gawk run at all, since it doesn't
understand single quotes and treats the < as an attempt to redirect
input to a file named 2.  This usually fails, but if you actually have
a file by that name, the result will depend on what's in that file
(which you didn't say).

Replacing single quotes with double quotes makes this program work as
I'd expect (i.e., print nothing), since COMMAND.COM then treats < as a
normal character.  The original command also works from Bash.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019