我有一个名为message的文件
CSC/UT/USA/WBIMB/SAP/orders05:orders05/ORDERS05/NONE/ORDRSP/758我正在做一个grep (平台是AIX6.1)
grep CSC/UT/USA/WBIMB/SAP/orders05:orders05/ORDERS05/NONE/ORDRSP/758 message它找到一行并显示输出。
但是,当我尝试使用通配符时,如下所示
grep CSC/UT/USA/WBIMB/SAP/orders05:orders05/ORDERS05/.*/ORDRSP/758 message它并不是在寻找线索。我也尝试过单引号/双引号。它不起作用。我在这里有遗漏什么吗?我很困惑。
发布于 2014-06-11 14:05:16
注意:我无法在AIX上测试这一点,但是下面的grep适用于我。
grep CSC/UT/USA/WBIMB/SAP/orders05:orders05/ORDERS05/.\*/ORDRSP/758 message或者另一种选择:
grep 'CSC/UT/USA/WBIMB/SAP/orders05:orders05/ORDERS05/.\+/ORDRSP/758' message这是因为在grep的基本正则表达式中,大多数元字符只有在转义时才有其特殊意义。来自grep手册页:
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose
their special meaning; instead use the backslashed versions \?, \+, \{,
\|, \(, and \).发布于 2014-06-11 17:07:08
试一试
egrep CSC/UT/USA/WBIMB/SAP/orders05:orders05/ORDERS05/*/ORDRSP/758 messagehttps://unix.stackexchange.com/questions/136595
复制相似问题