Skip site navigation (1)Skip section navigation (2)
Date:      12 May 2003 15:14:00 -0400
From:      Lowell Gilbert <freebsd-questions-local@be-well.no-ip.com>
To:        "Xpression" <admin@atenas.cult.cu>
Cc:        FreeBSD-questions <freebsd-questions@freebsd.org>
Subject:   Re: Making a shell script...
Message-ID:  <44y91casg7.fsf@be-well.ilk.org>
In-Reply-To: <000701c318b4$ecb460d0$fe01a8c0@libro>
References:  <000701c318b4$ecb460d0$fe01a8c0@libro>

next in thread | previous in thread | raw e-mail | index | archive | help
"Xpression" <admin@atenas.cult.cu> writes:

>             I try to make a script to rotate some log files every month,
> file must be appear like this   (Month-Year.tgz)...the question is: how can
> I compress all files in a sub-dir that contains many sub-dirs without
> compress sub-dirs too...sample:
> 
> /mydir/one-dir
>           /another-one
>           file1
>           file2
>           file3
> 
> I try to tar & compress file[1..3] without compress /one-dir, /another-one
> directories...I'm already looked at man pages without a response...thanks

This is what newsyslog(8) is for, but test(1) is what you're looking
for.  There may be a builtin version in your shell, but you can get
the one from the man page by specifying /bin/test.

Something like 

for fil in * ; 
do 
    if test -f $fil ; 
        then gzip $fil
    fi
done

[untested, and the syntax is for sh-style shells]



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44y91casg7.fsf>