awk and filenames with spaces.....
tony.arnold at manchester.ac.uk
Mon May 21 15:17:05 UTC 2007
David Koski wrote:
> I don't know about awk but this works although there is probably a better
> unzip -qql myzipfile.zip \
> | while read line; \
> do name=$(echo $line \
> | sed 's/^[^ ]*[ ]*[^ ]*[ ]*[^ ]*//'); \
> echo $name; done
You could also try using the cut command as follows:
unzip -l myfile.zip | cut -c 29-
which outputs from the 29th character onwards. Fortunately, unzip seems
to use fixed widths for its columns!
> On Monday 21 May 2007 02:19, Chris Malton wrote:
>> I'm trying to use awk in combination with unzip -l to list all the
>> filenames in a zip archive. The problem comes when there's a apce in
>> the filename, as unzip uses spaces as separators. How can I get awk to
>> print from a particular index onwards? Something like printing all
>> fields higher than index 4, for example.
>> Any ideas how?
Tony Arnold, IT Security Coordinator, University of Manchester,
IT Services Division, Kilburn Building, Oxford Road, Manchester M13 9PL.
T: +44 (0)161 275 6093, F: +44 (0)870 136 1004, M: +44 (0)773 330 0039
E: tony.arnold at manchester.ac.uk, H: http://www.man.ac.uk/Tony.Arnold
More information about the ubuntu-users