From owner-freebsd-questions Thu Jul 19 12:15:32 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mailb.telia.com (mailb.telia.com [194.22.194.6]) by hub.freebsd.org (Postfix) with ESMTP id 048A537B406 for ; Thu, 19 Jul 2001 12:15:22 -0700 (PDT) (envelope-from ertr1013@student.uu.se) Received: from d1o913.telia.com (d1o913.telia.com [195.252.44.241]) by mailb.telia.com (8.9.3/8.9.3) with ESMTP id VAA12013 for ; Thu, 19 Jul 2001 21:15:19 +0200 (CEST) Received: from ertr1013.student.uu.se (h185n2fls20o913.telia.com [212.181.163.185]) by d1o913.telia.com (8.8.8/8.8.8) with SMTP id VAA16345 for ; Thu, 19 Jul 2001 21:15:17 +0200 (CEST) Received: (qmail 14804 invoked by uid 1001); 19 Jul 2001 19:14:34 -0000 Date: Thu, 19 Jul 2001 21:14:33 +0200 From: Erik Trulsson To: Philipp Gaschutz Cc: Mikhail Teterin , questions@FreeBSD.ORG Subject: Re: AW: grep and \t (\r, etc.) Message-ID: <20010719211433.A14600@student.uu.se> Mail-Followup-To: Philipp Gaschutz , Mikhail Teterin , questions@FreeBSD.ORG References: <200107191814.f6JIEwO34105@aldan.algebra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.19i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jul 19, 2001 at 08:17:26PM +0200, Philipp Gaschutz wrote: > Hi! > > > find . -type -name '*.htm*' | xargs grep -E '\r$' > > > > just keeps listing all lines which end with ``r''... Any clues? > > Have you tried to replace ' with " ? > or ... \\r ? Won't help. If you check the manpage for grep you will see that the regular expressions it use don't know anything about control characters (including carriage return.) One solution is to make sure that the search pattern which gets passed to grep contains an actual carriage return. (Then grep will match that character literally just as it would with any normal character.) The following little C program will invoke grep in such a manner. It takes one filename as an argument which is then passed on to grep as the file to search through. It could be invoked instead of "grep -E '\r$'" above as long as you only pass it one filename at a time. #include #include char * args[] = { "grep", "\015$", NULL, NULL }; char * envp[] = { NULL }; int main(int argc,char *argv[]) { if(argc < 2) return EXIT_FAILURE; args[2] = argv[1]; execve("/usr/bin/grep",args,envp); exit(EXIT_FAILURE); } -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message