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 separator
  • rs - input record separator

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -