Shell – How to escape < or > in a parameter in shell

escape-charactersparameterquotingshell

I'd like to use grep with a PCRE expression that contains the < character. Bash thinks I want to redirect, but I don't want to. How can I escape <?

Best Answer

I was able to do it with a backslash:

25 % grep \< xmospos.c
#include        <stdio.h>
#include        <stdlib.h>
#include        <getopt.h>
#include        <X11/Xlib.h>

A quoted less-than, and a quoted, backslashed less than both gave goofy answers.

Related Question