Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case

Status
Not open for further replies.

ozi403

Technical User
Apr 29, 2002
54
0
0
TR
Hi,

My output like this :

name: odin;
browse policy: Year;
retention policy: Year;
group: ;

name: odin;
browse policy: Month;
retention policy: Year;
group: ;

So I want :
If group: is ";", don't show name, browse policy and retention policy.
Thanks for helps.
 
nawk -f ozi.awk myOutput

ozi.awk:
Code:
BEGIN {
  RS=FS=""
  ORS="\n\n"
}
$NF !~ /[ ][ ]*group:[ ][ ]*;$/

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Hi

Supposing that the sections are delimited with a blank line, this [tt]bash[/tt] script will read the file and store the lines until encounters a section limit. Then if anywhere in the last section was a group line with a value, then print the entire section.
Code:
sect=""; ok=0
while read str; do
  if test -z "$str"; then
    test $ok -eq 1 && echo "$sect"
    sect=""; ok=0
  else
    sect="$sect$str"$'\n'
    expr "$str" : "group: .\+;" > /dev/null && ok=1
  fi
done < datafile.txt

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top