How to match all lines that begins with word ADDRESS and the second string start with abc characters.
remark - ( I need to combine the sed synt开发者_StackOverflow社区ax in my shell script)
for example
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)
Not a sed answer, but this is a clear translation of your requirements:
awk '$1 == "ADDRESS" && substr($2,0,3) == "abc"'
Why not just do:
grep '^ADDRESS abc' input_file
sed -n '/^ADDRESS[ \t]*abc/p' file
I suggest you show us your code next time since i believe you are quite familiar with ksh/sed/awk etc already.
精彩评论