Because there are about 10000 files from October 6th, i need to to compress but i use this command and it does not do anything, in the prompt has no respones and i have to press CRTL+C to goback to the shell
for file in $(ls -l | grep "Impres" | grep "Oct 6"|grep -v .gz | awk '{print $9}');
do
gzip $file `
done
but if i list them, there are files from October 6th
CEL /produccion/explotacion/xpfactur/facturacion/log/ImpresionScl/nociclo # ls -l | grep "Impres" | grep "Oct 6"|grep -v .gz | >
bc
ImpresionScl_11715951.log
ImpresionScl_11762413.log
ImpresionScl_11762472.log
ImpresionScl_11763290.log
ImpresionScl_11763291.log
ImpresionScl_11763292.log
ImpresionScl_11763294.log
ImpresionScl_11797566.log
ImpresionScl_11864274.log
There must be a syntax error or somethink ?
The OS is SunOS
I appreciate your help in advanced
------ Post updated at 09:44 PM ------
I found the problem but i face this while overriding:
already exists; do you wish to overwrite (y or n)? not overwritten
Yes thank you it was a silly mistake i made, the initial problem was:
gzip $file `
yes there are not unique there are some from september.
but neither i dont want to overwrite them nor to be asked to overwrite, so i implemented this to skip if it really exists and redirect to a lof file the gzipped files:
for file in $(ls -l | grep "Impres" | grep "Oct 6"|grep -v .gz | awk '{print $9}');
do
if [-f $file]
echo "Skipped"
else
echo "compresing file $file" >> output.log
gzip $file
done
But its kind of a hassle because at least there are nearly 10000 files to gzip and log.
so is there any better approach to enhance this script and run faster?
So i do not rewrite from scratch, seems Scrutinizer already wrote some good code to run parallel gzips, with examples and multiple scenarios.
Of course, it's not one to fit all, you will have to adjust it to meet your needs a bit.
Post here if you get stuck with it or have any questions.