Issue
I would like to remove simple ' and double quotes " with bash command, but I can't remove ' with bash command. I don't know what I'm doing wrong but this command gives me an error, anyone have any idea?
user_download_dir_folder=$(echo ${user_download_dir_folder} | sed "s/\"\'//g")
Solution
Problem with sed "s/\"\'//g"
is that you're trying to match a "
followed by a '
. You should put them in bracket expression or match either of the quotes.
Let's say this is your input:
user_download_dir_folder="abc\"1'23'foo\"bla"
echo "$user_download_dir_folder"
abc"1'23'foo"bla
You may use sed
as this:
sed "s/[\"']//g" <<< "$user_download_dir_folder"
abc123foobla
Or in bash:
echo "${user_download_dir_folder//[\'\"]/}"
abc123foobla
Answered By - anubhava Answer Checked By - David Goodson (WPSolving Volunteer)