print a paragraph that contains more than 2 patterns using awk or sed -
i want print paragraphs begin "select" , end ";", should contain "in cccc" example if have following code
select aaaa bbbb in cccc ; select dddd eeeee in ffff ; select rrrr eeeee in cccc ; the result
select aaaa bbbb in cccc ; select rrrr eeeee in cccc ; so here's awk used awk '/^select*/,/^;/{if ($0 ~ /^in cccc/) ; print}' inputfile result entire content of file
you can try awk:
awk 'begin{ors=rs=";"} /^[[:space:]]*select.*in cccc/' file here,
ors- output record separatorrs- input record separator
Comments
Post a Comment