Missing First Line when using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Missing First Line when using awk
# 1  
Old 09-01-2015
Missing First Line when using awk

Hi there,

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

Code:
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>'

Code:
File summary_h8cc0203v.txt:
BUILTIN\Administrators:(RX)
NT AUTHORITY\SYSTEM:(RX)
BUILTIN\Users:(RX)

Code:
C:\Windows\Fonts CREATOR OWNER:(OI)(CI)(IO)(F):
BUILTIN\Administrators:(RX)
NT AUTHORITY\SYSTEM:(RX)
BUILTIN\Users:(RX)

# 2  
Old 09-01-2015
Move the /Windows\\fonts\\/ {P=1} before the P {print $0"<br>"} action (print if P is non-zero).
This User Gave Thanks to MadeInGermany For This Post:
# 3  
Old 09-01-2015
Thank you so much!

Code:
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>'

Code:
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)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getopts how to handle missing '-' in command line args.

I'm using getopts to process command line args in a Bash script. The code looks like this: while getopts ":cfmvhs:t:" option; do case $option in c) operationMode="CHECK" ;; f) operationMode="FAST" ;; m) ... (6 Replies)
Discussion started by: gencon
6 Replies

2. Shell Programming and Scripting

Print a line where missing!!

Hi, I have a file whihc looks like file_1 100 200 file_2 200 300 file_4 400 500 as the file_3 is missing so I want to replace it by file_3 0 0 the final output would look like file_1 100 200 file_2 200 300 file_3 0 0 file_4 400 500 Any help is highly appreciated. Regards, (1 Reply)
Discussion started by: begin_2013
1 Replies

3. Shell Programming and Scripting

Script to output a line missing a number

Ok, Lets see if I can explain this We have a script that pulls information from multiple files and outputs it, however I only need 2 Columns (of 11) from it right now I run the script like this: tkxtrn | awk '{print $5" "" "$9}' This gives me column 5 and 9, the only two I care for ... (5 Replies)
Discussion started by: shadowkraze
5 Replies

4. Shell Programming and Scripting

[Solved] line breaks missing when emailed from unix to win

hi i am sending an email from unix to windows platform and using uuencode to attach the plain text files (.txt). But when i read the attached file in notepad the linebreaks are gone. uuencode samplefile.txt samplefile.txt | mail -s "test email" <mailid.com> if i copy paste the... (6 Replies)
Discussion started by: midhun19
6 Replies

5. Shell Programming and Scripting

Subject line missing while sending mail

Hi, I have below script PROJECT_NAME=UDL/UDL_Weekly sub= echo ${PROJECT_NAME}|cut -d "/" -f2 cat pr.sh|mail -s "`hostname`: $sub failed" sonu.pal@xyz.com While running the script I am receiving the subject line in mail as " podetlsapp01: failed' instead of " podetlsapp01: ... (1 Reply)
Discussion started by: sonu_pal
1 Replies

6. Shell Programming and Scripting

command-line line 0: Missing yes/no argument

Hi Guys When I run the below command ssh -o 'PasswordAuthentication yes' -o 'PreferredAuthentications publickey' -i $HOME/.ssh/id_dsa Server_Name I found the below error ommand-line line 0: Missing yes/no argument Kindly help me to sort out Double post, continued... (0 Replies)
Discussion started by: Pratik4891
0 Replies

7. Shell Programming and Scripting

Unix find missing new line

Hi All, I wanted to check out a missing new line character from last line on Unix. If file is having newline character at the end of last line then it should show as "\n" else will display the last character whatever it is. OR If file is having newline character at end of last line... (8 Replies)
Discussion started by: gr8_usk
8 Replies

8. Shell Programming and Scripting

join based on line number when one file is missing lines

I have a file that contains 87 lines, each with a set of coordinates (x & y). This file looks like: 1 200.3 -0.3 2 201.7 -0.32 ... 87 200.2 -0.314 I have another file which contains data that was taken at certain of these 87 positions. i.e.: 37 125 42 175 86 142 where the first... (1 Reply)
Discussion started by: jackiev
1 Replies

9. Shell Programming and Scripting

Awk not working due to missing new line character at last line of file

Hi, My awk program is failing. I figured out using command od -c filename that the last line of the file doesnt end with a new line character. Mine is an automated process because of this data is missing. How do i handle this? I want to append new line character at the end of last... (2 Replies)
Discussion started by: pinnacle
2 Replies

10. Shell Programming and Scripting

AWK with a variable - am I missing something??

I've got a file - for example: A B C D E 21134570 1 21573 XXXX XXXX 21134570 1 21574 XXXX XXXX 21134570 1 21575 XXXX XXXX 21134577 1 21569 XXXX XXXX 21134571 1 21566 XXXX XXXX 21134566 1 ... (4 Replies)
Discussion started by: Cailet
4 Replies
Login or Register to Ask a Question