The output of each awk
processed line is terminated in a linefeed (\n
) which is the Unix/Linux standard. Windows/DOS expects a carriage return followed by a linefeed to mark the end of the line (\r\n
). notepad
will display all Linux generated files as you are currently seeing them.
To resolve, pipe the output of awk
through the unix2dos
command, which converts n
s to \r\n
s for you:
unzip -l my.zip | awk '{print $4}' |unix2dos > my.txt
Alternatively, try telling awk
to output \r\n
at the end of each line using the ORS
variable:
unzip -l my.zip | awk -v ORS='\r\n' '{print $4}' > my.txt
To list without header and footer:
unzip -l my.zip | awk -v ORS='\r\n' '{print $4}' | tail -n +4 | head -n -2 > my.txt
Or
Alternatively, use zipinfo -1 <zip file>
(number 1, not letter l) to list files without a header and footer. You may still need to pipe it through unix2dos
. Useful only if zipinfo
is available in CygWin.