home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!darwin.sura.net!newsserver.jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!uknet!sni!wstuart!stephen
- From: stephen@wstuart
- Newsgroups: comp.unix.shell
- Subject: Re: help with a script files
- Message-ID: <1993Jan28.152735.2246@sni.co.uk>
- Date: 28 Jan 93 15:27:35 GMT
- References: <1993Jan26.203636.7606@aruba.uucp>
- Sender: news@sni.co.uk (Usenet News)
- Reply-To: stuart@siesoft.co.uk
- Organization: Siemens Nixdorf Information Systems Ltd.
- Lines: 50
- X-Newsreader: Tin 1.1 PL4
-
- rickt@aruba.UUCP (Rickey Thomas Tom) writes:
- : I a working on a script that basicaly moves files from a subdirectory to
- : a current directory.
- :
- : The problem is that if there are no files in the subdirectory, the script
- : terminates and returns an error code that says that no files were found.
- :
- : I tried if ( -e "<dir x>/* ) then
- : .....
- :
- : but this does not work either
- :
-
- It appears that you are using csh for your scripts.
-
- In my experience csh is harder to use, more bug-ridden
- and less portable than sh and so recommend that you use
- sh for your scripts. (By all means use, as I do, csh
- for an interactive shell.)
-
- In sh, you can do exactly as you tried (obviously the
- sytax is different):
-
- if test -f <dir x>/*
- then
- # there exist files in <dir x>
- else
- # there are no files in <dir x>
- fi
-
- In csh, if you must:
-
- set nonomatch
- if ( -e <dir x>/* ) then
- # there exist files
- else
- # there don't
- endif
-
- Note: 1. this still fails if <dir x> doesn't exist
- 2. "-e <dir x>/*" returns true for both directories
- and files
-
-
- Stuart
- -
- --
- S I E M E N S Stuart Hood === Siemens Nixdorf House, Bracknell, Berks, UK
- ------------- Phone: + 44-344-850892 Email: stuart@siesoft.co.uk
- N I X D O R F - Never let ignorance stand in the way of a good argument -
-