Get the two parameter from text file in UNIX.

Hi there,

In my attachment there is 'Category/Subcategory' & 'Setting'.

var=$(awk '/^Logon\/Logoff/ {P=0} P {print $0} FNR==1{printf("From file %s:\n", FILENAME)} /^System/ {P=1}' $file |grep -ia "IPsec Driver"              );echo $var

As of now I am able to

From File: Policies.txt IPsec Driver                            Success and Failure

It will be best if I can just get

From File: Policies.txt Success and Failure
Category/Subcategory                 Setting
System
  Security System Extension      Success and Failure
  System Integrity                      Success and Failure
  IPsec Driver                            Success and Failure
  Other System Events              No Auditing
  Security State Change              Success and Failure

The constraint was that they are seperated by multiple spaces.

Is that what you're after?

var=$(awk '
    FNR==1 {printf "From file: %s ", FILENAME}
    /^Logon\/Logoff/ {P=0}
    P && /IPsec/ {print substr($0, 43)}
    /^System/ {P=1}
'test.file)

Why not

awk '
/^Logon\/Logoff/        {P=0}
P && /IPsec/            {printf "From file: %s; %s\n", FILENAME, substr($0, 43)}
/^System/               {P=1}
' /tmp/audit_nac1051.txt