[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Transform strings with special characters so that the string
From: |
Peng Yu |
Subject: |
[Help-bash] Transform strings with special characters so that the strings don't need to be quoted? |
Date: |
Tue, 24 Mar 2015 17:13:06 -0500 |
Hi,
Suppose that I have a variable with special characters, e.g, single
quote, double quote. How to transform the variable so that it can be
used without being quoted (for example "x'y" -> x\'y)?
One use case is something like the following. I want to construct a
diff command on the results of calling myscript on multiple files. The
following code works but not robustly with respect to any possible
filenames. Does anyone know the best solution in this case?
cmd=diff
for n
do
cmd="$cmd <(myscript '$n')"
done
eval "$cmd"
--
Regards,
Peng
- [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?,
Peng Yu <=
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Eduardo A . Bustamante López, 2015/03/24
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Eric Blake, 2015/03/25
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Eric Blake, 2015/03/25
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Chet Ramey, 2015/03/26
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Eric Blake, 2015/03/26
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Stephane Chazelas, 2015/03/29