Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Feb 1997 17:23:37 -0800 (PST)
From:      Dan Busarow <dan@dpcsys.com>
To:        David Chamberlain <DavidC@OIAPDX.yoshida.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Stupid shell question
Message-ID:  <Pine.UW2.3.95.970207172002.2651A-100000@cedb>
In-Reply-To: <s2fb4de8.025@yoshida.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 7 Feb 1997, David Chamberlain wrote:
> I am trying to write an if statement in a shell script that executes a
> series of lines if *any* file exists in a specified directory.  Ie:
> 
> if [ file exists in send dir ]

cd sned_dir
for i in *			# if send_dir is empty $i gets set to a literal "*"
do
	if [ -f $i ]	# make sure $i is a regular file
	then
		do this
		and this
	fi
done

Have fun

Dan
-- 
 Dan Busarow                                                  714 443 4172
 DPC Systems / Beach.Net                                    dan@dpcsys.com
 Dana Point, California  83 09 EF 59 E0 11 89 B4   8D 09 DB FD E1 DD 0C 82




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.UW2.3.95.970207172002.2651A-100000>