Search by patterns case

 
42   network read failed
sv1 sv23 sv4
sv11 sv23 sv5 sv 7
48  client hostname could not be found
sv21 sv78 sv19 sv22
sv111 sv203 sv5 sv 33
49  client did not start
sv1 sv21
54   timed out connecting to client
sv2 sv4 sv12

above is my file , I'd like to use a script to list all name below the line that starts with "48 client hostname.." untill it finds a line starts with a number in the this case 49. it can be any other number

so the output of would be

 
sv21 sv78 sv19 sv22
sv111 sv203 sv5 sv 33

Thaanks

Hi,
Try this one,

awk '/^48/,/^49/'{print $0;} file

Cheers,
Ranga:-)

this one wokrks , but the second number can be different thatn 49

i tried this , but it didnt work fine

 
awk '/^48/,/^[0-9]/'{print $0;} file

What about in sed?
Anyway try this,

awk '/^48/{t=1;next;}t==1 && $0 !~ /^[0-9]/{print;}/^[0-9]/{t=0;}' file

Cheers,
Ranga:-)

1 Like

works perfectly :blush:

Shortened it a bit:

awk '/^[0-9]/{p=0}p;/^48/{p=1}' file
1 Like