I have a FILE variable in bash which I want replace RT in FILE's value to TTT.
Operations:
FILE="BlazeRT 123"
source_dir=BlazeRT
target_dir=BlazeTTT
newfile="$(echo ${FILE} | sed -e \"s/${source_dir}/${target_dir}/g\")"
I got error:
sed: -e expression #1, char 1: unknown command: `"'
Seems the error occurs when shell eval echo ${FILE} | sed -e \"s/${source_dir}/${target_dir}/g\".
Now, I wanna know ho to correct the last command.
Thanks in advance!
sed -e "s/${source_dir}/${target_dir}/g"? – Inian Sep 24 '21 at 11:13newfile="${FILE/$source_dir/$target_dir}"– Bodo Sep 24 '21 at 11:31FILEand assignment itnewfile. – roachsinai Sep 24 '21 at 11:41set -xbeforenewfile=...(andset +xafterwards). – Bodo Sep 24 '21 at 11:48()which let bash know the couple between those four"s? – roachsinai Sep 24 '21 at 11:51cmd) in *sh shells been deprecated? and http://mywiki.wooledge.org/BashFAQ/082 for the – ilkkachu Sep 30 '21 at 20:24