Date: Sun, 6 Jul 1997 17:37:05 +0300 (IDT) From: Eli Zaretskii To: Nate Eldredge cc: djgpp AT delorie DOT com Subject: Re: Escaped chars in regexps In-Reply-To: <199707041643.JAA18466@adit.ap.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Fri, 4 Jul 1997, Nate Eldredge wrote: > Does anybody know of a way to allow the use of escaped characters (\n, \b, > \t for newline, backspace, tab) in regexps for `grep' and `sed'? You can't. These sequences aren't part of regexp syntax; you can have them when you call regexp functions from a C program, but that's because the compiler automatically converts any \t etc. in character strings. Why can't you just use the character itself? For example, this works for me: sed -n -e /^TAB/p Makefile (where I actually pressed the TAB key inside the slashes). This command prints all the lines which begin with a TAB. For characters such as BS (which cannot be easily typed on the keyboard), create a text file with the Sed sommand using your favorite editor and use it with -f: sed -f script ... Any decent editor will allow you to put any ASCII character, including a backspace, into a file. (Incidentally, some keyboard enhancers actually allow you to type BS verbatim using some kind of quote character; with Bash, use Ctrl-Q.)