Missing First Line when using awk

Hi there,

I was using the following awk statement but the first line is missing

dirlist=(`ls summary*`); #list all the files in a directory and store them into a variable

echo '<table border='1'>'      
echo '<tr><td>%windir%\fonts\*.* </td><td>'         ; awk '/Successfully/ {P=0} P {print $0 "<br>"} FNR==1{printf("File %s:<br>", FILENAME)}  /Windows\\fonts\\/ {P=1} '                 ${dirlist
[*]}   ;echo '</td></tr>'
echo '</table>'                                                                          
File summary_h8cc0203v.txt:
BUILTIN\Administrators:(RX)
NT AUTHORITY\SYSTEM:(RX)
BUILTIN\Users:(RX)
C:\Windows\Fonts CREATOR OWNER:(OI)(CI)(IO)(F):
BUILTIN\Administrators:(RX)
NT AUTHORITY\SYSTEM:(RX)
BUILTIN\Users:(RX)

Move the /Windows\\fonts\\/ {P=1} before the P {print $0"<br>"} action (print if P is non-zero).

1 Like

Thank you so much!

echo '<tr><td>%windir%\fonts\*.* </td><td>'         ; awk '/[Cc]:/ {P=0} /C:\\Windows\\Temp/   {P=1} P {print $0 "<br>"} FNR==1{printf("File %s:<br>", FILENAME)}'     ${dirlist
[*]}   ;echo '</td></tr>'


File summary_h8cc0203v.txt:
C:\Windows\Temp CREATOR OWNER:(OI)(CI)(IO)(F)
                NT AUTHORITY\SYSTEM:(OI)(CI)(F)
                BUILTIN\Administrators:(OI)(CI)(F)
                BUILTIN\Users:(CI)(S,WD,AD,X)
                BUILTIN\IIS_IUSRS:(OI)(CI)(S,RD)
                (OI)(CI)(F)
                (OI)(CI)(RX)
                H8CC0203V\WSS_ADMIN_WPG:(OI)(CI)(F)
                H8CC0203V\WSS_WPG:(OI)(CI)(RX)
                STBHQRBS\epprbssp_setup:(OI)(CI)(F)
                (OI)(CI)(RX,WD,AD)