Read a file line by line

Hi everybody,

I have a config file what looks like this

# name name
#host TYPE-IFTYPE-user{
#       hardware ethernet 00:00:00:00:00:00;
#       fixed-address 0.0.0.0;
#}

## unknown
#host TYPE-IFTYPE-USER{
#       hardware ethernet 00:00:00:00:00:00;
#       fixed-address 0.0.0.0;
#}

# name name
#host TYPE-IFTYPE-user{
#       hardware ethernet 00:00:00:00:00:00;
#       fixed-address 0.0.0.0;
#}

## unknown
#host TYPE-IFTYPE-USER{
#       hardware ethernet 00:00:00:00:00:00;
#       fixed-address 0.0.0.0;
#}

so what i want is to write a script what reads the config file line by line and print only the unknown patterns and the following three lines into a text file.

I dont know how to tell the script read from here to here begin at every unknown pattern.

Please help me

thanx

grep -A3 'unknown' cfgfile

This works nice!!!:slight_smile:

Thank you very much!!!

 sed -n '/unknown/{N;N;N;p;}' file

works too!!!

thanks