2 tab are taken into account
source | link

with a awk and a parameter

(file filter.awk)

BEGIN { p=0 ; } # no printing
 { if ( (substr($0,1,1) != " ") && (substr($0,1,1) != "\t" ) ) p=0 ; # if no blank stop printing
   if ( index($0,name) > 1 ) p=1 ; # pattern found ?
  if (p) print ;
 }
  • $0 is the entire line
  • substr($0,1,1) is first caracter of line

and the result

awk -v name=apollo -f filter.awk a.txt

    com.apollo.apollonetworkcheck
     1026ms running, 88 wakeups
     88 alarms: flg=0x14

with a awk and a parameter

(file filter.awk)

BEGIN { p=0 ; } # no printing
 { if ( substr($0,1,1) != " " ) p=0 ; # if no blank stop printing
   if ( index($0,name) > 1 ) p=1 ; # pattern found ?
  if (p) print ;
 }
  • $0 is the entire line
  • substr($0,1,1) is first caracter of line

and the result

awk -v name=apollo -f filter.awk a.txt

    com.apollo.apollonetworkcheck
     1026ms running, 88 wakeups
     88 alarms: flg=0x14

with a awk and a parameter

(file filter.awk)

BEGIN { p=0 ; } # no printing
 { if ( (substr($0,1,1) != " ") && (substr($0,1,1) != "\t" ) ) p=0 ; # if no blank stop printing
   if ( index($0,name) > 1 ) p=1 ; # pattern found ?
  if (p) print ;
 }
  • $0 is the entire line
  • substr($0,1,1) is first caracter of line

and the result

awk -v name=apollo -f filter.awk a.txt

    com.apollo.apollonetworkcheck
     1026ms running, 88 wakeups
     88 alarms: flg=0x14
1
source | link

with a awk and a parameter

(file filter.awk)

BEGIN { p=0 ; } # no printing
 { if ( substr($0,1,1) != " " ) p=0 ; # if no blank stop printing
   if ( index($0,name) > 1 ) p=1 ; # pattern found ?
  if (p) print ;
 }
  • $0 is the entire line
  • substr($0,1,1) is first caracter of line

and the result

awk -v name=apollo -f filter.awk a.txt

    com.apollo.apollonetworkcheck
     1026ms running, 88 wakeups
     88 alarms: flg=0x14