Regex sed+;将行中的第一个单词与以abc开头的第二个单词匹配

Regex sed+;将行中的第一个单词与以abc开头的第二个单词匹配,regex,shell,sed,Regex,Shell,Sed,如何匹配以单词地址开头的所有行 第二个字符串以abc字符开头 备注-(我需要在shell脚本中组合sed语法) 比如说 more file ADDRESS abc1a (match) ADDRESS abc1b (match) ADDRESS acb1a (will not match) ADRESS abc (will not match) ADDRESS abc2a (will match) ADDRES abc1a (will not match) ADDRESS

如何匹配以单词地址开头的所有行 第二个字符串以abc字符开头

备注-(我需要在shell脚本中组合sed语法)

比如说

 more file

 ADDRESS abc1a (match)
 ADDRESS abc1b (match)
 ADDRESS acb1a (will not match)
 ADRESS  abc   (will not match)
 ADDRESS abc2a (will match)
 ADDRES  abc1a (will not match)
 ADDRESS ab    (will not match)
为什么不干脆做:

grep '^ADDRESS abc' input_file

我建议您下次向我们展示您的代码,因为我相信您已经非常熟悉ksh/sed/awk等。

不是sed答案,但这是您需求的清晰翻译:

awk '$1 == "ADDRESS" && substr($2,0,3) == "abc"'

sed-n'/[\t]*ADDRESS[\t]*abc/p'文件(如果在行首到地址之间的行中有空格,我会更正此错误)您可能希望空格模式使用
\+
,而不是
*
,以确保至少有一个空格
awk '$1 == "ADDRESS" && substr($2,0,3) == "abc"'