On 4 June 2016 at 22:40, Vincent Belaïche <[email protected]> wrote:
> These two things also work:
>
> --8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
> in_input_funnies=`echo "$in_input" \
> | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1\'"
> "'!g' \
> | uniq`
> --8<----8<----8<----8<----8<-- end -->8---->8---->8---->8---->8----
>
> --8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
> in_input_funnies=`echo "$in_input" \
> | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1\''
> ''!g' \
> | uniq`
> --8<----8<----8<----8<----8<-- end -->8---->8---->8---->8---->8----
>
> but I prefer the one with "$newline" to keep the sed command on the same
> line.
Nice idea to hide it in a variable.
I'd come up with
in_input_funnies=`echo "$in_input" \
| $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1'\\\\'
''!g' \
| uniq`
which is fairly similar to the two examples above you gave, except
it's less clear. (Four backslashes because backslash escaped once for
the shell, and once for the ``-expression.)