I'm looking for something that will translate a string as follows, using only bash / standard Linux commands:
This should do it:
sed "s/^\([\"']\)\(.*\)\1\$/\2/g" in.txt
Where in.txt is:
"Fo'od' 'Food' "Food" "Fo"od' Food 'Food" "Food' 'Fo'od' "Fo'od" Fo'od 'Fo"od' "Fo"od" Fo"od
And expected.txt is:
"Fo'od' Food Food "Fo"od' Food 'Food" "Food' Fo'od Fo'od Fo'od Fo"od Fo"od Fo"od
You can check they match with:
diff -s <(sed "s/^\([\"']\)\(.*\)\1\$/\2/g" in.txt) expected.txt
You could use
echo "$string" | tr -d 'chars to delete'
... also works, however 'tr' is known to be problematic on much older (circa Redhat 9-ish) distributions.
tr is an abbreviation for 'translate', commonly used in pipes to transform input. The
-d option simply means 'delete'.
Most modern versions also contain predefined macros to transform upper to lower, lower to upper, kill white space, etc. Hence, if you use it, take a second to poke at what else it does (see the help output / man page), comes in handy.