Re: Whitespace in filenames
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Mon, 27 Feb 2006 14:28:57 -0500
On 2006-02-27, soup_or_power@xxxxxxxxx wrote:
I have inherited some code that looks like this:
if [ ! -f $file ]
then
echo "Error Can't clean >$file<. May have spaces in the
name?"
else
mv "$file" DEL.$file
fi
Quote your variables:
if [ -f "$file" ]
then
mv "$file" "DEL.$file"
else
echo "Error: >$file< does not exist"
fi
I have these questions:
a) can it be rewritten as if [ ! -f "$file" ]...
b) change the mv as mv "$file" "DEL.$file"
Exactly.
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.
- References:
- Whitespace in filenames
- From: soup_or_power
- Whitespace in filenames
- Prev by Date: Re: make rpm packages for all linux distributions
- Next by Date: Re: Random ip problem when login Debian via putty
- Previous by thread: Whitespace in filenames
- Next by thread: Re: Whitespace in filenames
- Index(es):
Relevant Pages
|