Re: How do I get a list of filenames with spaces on bash?
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 24 Jan 2008 16:32:00 GMT
On Thu, 24 Jan 2008 09:00:27 -0600, Ed Morton wrote:
[...]
for f in *\ *
do
n="${f// /_}"
[ ! -f "$n" ] &&
[ -f ... ] test whether the file exists *and* is a regular file
(or symlink to regular file). What if it exists and is a
directory?
cp -- "$f" "$n" &&[...]
rm -- "$f"
done
Why not mv? cp won't work great for non-regular files.
A better way to avoid overwriting files is to use the -i option
of cp/mv. See also (set -C; cat < in > out)
--
Stephane
.
- Follow-Ups:
- Re: How do I get a list of filenames with spaces on bash?
- From: Ed Morton
- Re: How do I get a list of filenames with spaces on bash?
- References:
- Re: How do I get a list of filenames with spaces on bash?
- From: jellybean stonerfish
- Re: How do I get a list of filenames with spaces on bash?
- From: Chad
- Re: How do I get a list of filenames with spaces on bash?
- From: Ed Morton
- Re: How do I get a list of filenames with spaces on bash?
- Prev by Date: Re: command substitution error using bash
- Next by Date: Re: How do I get a list of filenames with spaces on bash?
- Previous by thread: Re: How do I get a list of filenames with spaces on bash?
- Next by thread: Re: How do I get a list of filenames with spaces on bash?
- Index(es):
Relevant Pages
|