Re: how to escape special chars in filenames
Chris F.A. Johnson wrote:
> On 2006-08-21, Jerry Fleming wrote:
>> I have a list (about 600) of files whose names contain special
>> characters, such as spaces, &, (. Under bash, they have to be escaped. I
>> was wondering if there is any command, or even a piece of sed, which can
>> be used to escape them.
>
> How are you using the names?
>
> The usual method is to quote the file name:
>
> for file in ./*
> do
> cat "$file"
> done
>
I am using the names with scp:
scp special_file root@host:~/"special_file"
Here I have to quote the destination special_file twice, one with double
quotes, one with escapes. Only double quotes won't work. I am wondering
how to escape special chars of filenames in a script.
|