如何在shell中的参数中转义<或>?

hak*_*kre 10 shell parameter quoting escape-characters

我想grep与包含该<字符的 PCRE 表达式一起使用。Bash 认为我想重定向,但我不想。我怎样才能逃脱<

Bru*_*ger 12

我可以用反斜杠做到这一点:

25 % grep \< xmospos.c
#include        <stdio.h>
#include        <stdlib.h>
#include        <getopt.h>
#include        <X11/Xlib.h>
Run Code Online (Sandbox Code Playgroud)

引用的小于和引用的反斜杠小于两者都给出了愚蠢的答案。

  • 是的,或者把它放在单引号中 (5认同)