From owner-freebsd-questions@FreeBSD.ORG Mon May 12 12:14:11 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA03837B401 for ; Mon, 12 May 2003 12:14:11 -0700 (PDT) Received: from sccrmhc01.attbi.com (sccrmhc01.attbi.com [204.127.202.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id DD57F43FBF for ; Mon, 12 May 2003 12:14:06 -0700 (PDT) (envelope-from freebsd-questions-local@be-well.no-ip.com) Received: from be-well.ilk.org (lowellg.ne.client2.attbi.com[24.147.188.198]) by attbi.com (sccrmhc01) with ESMTP id <2003051219140600100orhu2e>; Mon, 12 May 2003 19:14:06 +0000 Received: from be-well.ilk.org (lowellg.ne.client2.attbi.com [24.147.188.198] (may be forged)) by be-well.ilk.org (8.12.9/8.12.7) with ESMTP id h4CJE1uD091741; Mon, 12 May 2003 15:14:05 -0400 (EDT) (envelope-from freebsd-questions-local@be-well.no-ip.com) Received: (from lowell@localhost) by be-well.ilk.org (8.12.9/8.12.6/Submit) id h4CJE01g091738; Mon, 12 May 2003 15:14:00 -0400 (EDT) X-Authentication-Warning: be-well.ilk.org: lowell set sender to freebsd-questions-local@be-well.ilk.org using -f Sender: lowell@be-well.no-ip.com To: "Xpression" References: <000701c318b4$ecb460d0$fe01a8c0@libro> From: Lowell Gilbert Date: 12 May 2003 15:14:00 -0400 In-Reply-To: <000701c318b4$ecb460d0$fe01a8c0@libro> Message-ID: <44y91casg7.fsf@be-well.ilk.org> Lines: 30 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: FreeBSD-questions Subject: Re: Making a shell script... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2003 19:14:12 -0000 "Xpression" 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]