Jack Vo wrote:
Hi all,
Hello,
I need to compress many files in a directory on server. I use "awk" and
"zip" command to compress these files.
By "awk" command, I filter theses file :
*# ls -latr | grep iMAP.med0 | awk '{print $9}'*
You are doing way too much just to get the correct file names. The
shell's globbing function should suffice:
echo iMAP.med0*
iMAP.med0101_agent.trace.20120726153046.tar.gz
iMAP.med0101_agent.trace.20120726152942.tar.gz
iMAP.med0107_agent.trace.20120726154526.tar.gz
iMAP.med0101_agent.trace.20120726154741.tar.gz
iMAP.med0101_agent.trace.20120726154616.tar.gz
iMAP.med0101_agent.trace.20120726154436.tar.gz
iMAP.med0105_agent.trace.20120726154555.tar.gz
iMAP.med0101_agent.trace.20120726154532.tar.gz
iMAP.med0101_agent.trace.20120726154700.tar.gz
iMAP.med0101_agent.trace.20120726154720.tar.gz
How many files are in each tar archive?
I want to compress them to trace_file.zip, and I use the command, but
can not zip these files. Which parameters or syntax did I wrong ?
*# ls -latr | grep iMAP.med0 | awk '{ system("zip /tmp/trace_file" $9)}'*
# ls -latr /tmp/ | grep trace_file
You could un-tar them first and then zip the reulting files:
tar -xzf iMAP.med0*
zip trace_file.zip *
Or perhaps something like this would work.
tar -xzf iMAP.med0* | zip trace_file.zip -
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/