Date: Sat, 31 May 1997 22:59:44 +0200 From: Gerhard Sittig <G.Sittig@abo.freiepresse.de> To: Gianmarco Giovannelli <gmarco@giovannelli.it> Cc: FreeBSD-questions <FreeBSD-Questions@FreeBSD.ORG> Subject: Re: test and multiple files ... Message-ID: <33909140.40FE@abo.freiepresse.de> References: <3.0.1.32.19970529201527.00697bd8@giovannelli.it>
next in thread | previous in thread | raw e-mail | index | archive | help
Gianmarco Giovannelli wrote: > > How it is possible use the test command with multiple files ? > > i.e. > > if [ -f /usr/tmp/src-2.2* ]; then > mv /usr/tmp/src-2.2.????.gz > /home/ftp/pub/FreeBSD/FreeBSD-2.2/ctm > fi > > seems not to work for me.... > In all the cases where wildcards are used, it's a good idea (seems to me at least :) to use an `echo` command and see what command the shell will generate after expanding these patterns. In the above example the code will read somewhat like if [ -f file1 file2 file3 ]; then ... which does work when only ONE file is matched and MIGHT work this way without being noticed of that error. But referring to the 'test' synopsis this is of course a mistake. One solution for the above problem would be for file in /usr/tmp/src-2.2*; do if [ -f $file ]; then mv $file $destdir; fi done which will even cope with non matchinng files (i.e. empty lists). This might look somewhat more of a circumstance compared to Doze, but it would be even worse when wildcards wouldn't work :)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33909140.40FE>