Re: How do I get a list of filenames with spaces on bash?
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Thu, 24 Jan 2008 17:16:01 -0600
On 1/24/2008 11:38 AM, Stephane Chazelas wrote:
On Thu, 24 Jan 2008 11:04:29 -0600, Ed Morton wrote:
[...]
[...]cp -- "$f" "$n" &&
rm -- "$f"
Why not mv? cp won't work great for non-regular files.
To ensure that in the event of a failure the original file is unaffected.
in that case, mv doesn't affect the file not even its inode, it
affects the current directory, it's just a rename. A failing
rename just leaves things as they are.
Huh, I didn't realise that "mv" was totally safe. Then I'd just use:
for f in *\ *
do
n="${f// /_}"
[ ! -f "$n" ] &&
mv -- "$f" "$n"
done
Thanks for the tip.
Ed.
.
- 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?
- From: Stephane Chazelas
- 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?
- From: Stephane Chazelas
- Re: How do I get a list of filenames with spaces on bash?
- Prev by Date: Re: Extract block of text
- Next by Date: Re: Bash script to subtotal a column in a file
- 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
|