Remove all line below the pattern

I have few files i want to delete all line before match and also print the match line. like

Can anyone help.

awk '/ccd/ { P=1 } P'

Thanks corona688.

But now my problem is i want to print my pattern also. as i mention above.

sed -e '0,/ccd/d' tmp OR awk '/ccd/ { P=1 } !P' tmp
awk -v PAT="ccd" 'BEGIN { printf("match pattern '%s'\n\n", PAT); }; $0 ~ PAT { P=1 } P'
1 Like
 
$ awk '/ccd/{print;exit}1' test.txt
aab
bbc
ccd

1 Like
awk '1;/ccd/{exit}' file
sed '/ccd/q' file
1 Like

Try like..

sed '1,/ccd/!d' inputfile

Guys here is the new problem i have. all above command are search the pattern up to 3 word. like i have 15 letters strings. It's only search for 3 word and give me out put. i need to search for whole pattern and than remove the rest of the lines. my file have similar kind of strings.

In sort all the above doesn't satisfy my requirement.

It needs to match only entire lines? Okay:

awk '/^merchant$/{print;exit}1' tmp1