is it possible to filter, i.e to put ESC in front of the inner quotes with sed, awk or other *NIX tool (no perl/python)? Example (revised):$ echo label=\123 \456\ 789\ \AB C\ e f gh | magic-filterlabel=123 \456\ 789\ \AB C e f ghlabel=123 \456\ 789 AB C In other words a filter is needed that will filter in the following way:the first and last  char will be passed as is, but all other  will be replaced with \ followed by .
how to filter inner quotes?
awk;regular expression;quoting;special characters
With GNU sed, which supports replacing all occurrences from particular count$ echo label=\123 \456\ 789\ \AB C\ e f gh | sed -E 's//\\/2g; s/\\([^]*)$/\1/'label=123 \456\ 789\ \AB C e f ghAll  (expect first ) are replaced with \ and then \ is removed from last \If GNU sed is not available, remove \ from first \ as well$ echo label=\123 \456\ 789\ \AB C\ e f gh | sed -E 's//\\/g; s/\\//; s/\\([^]*)$/\1/'label=123 \456\ 789\ \AB C e f ghNote: Some sed versions use -r option instead of -E for extended regexWith perl$ echo label=\123 \456\ 789\ \AB C\ e f gh | perl -pe 's/(^[^]*|[^]*$)(*SKIP)(*F)|/\\/g'label=123 \456\ 789\ \AB C e f ghHere, the string up to first  and string from last  to end of line are skipped while the remaining  are replaced with \