linuxbashfedoraarchlinuxbash4

In BASH, How do i replace \r from a variable that exist in a file written using HTML <textarea></textarea>


How do i replace the \r?

#!/bin/bash
...

# setup
if [[ $i =~ $screen ]]; then

    ORIGINAL=${BASH_REMATCH[1]}          # original value is: 3DROTATE\r
    AFTER   =${ORIGINAL/\\r/}            # does not replace \r
    myThirdPartyApplication -o $replvar  # FAILS because of \r

fi

Solution

  • You could use sed, i.e.,

    AFTER=`echo $ORIGINAL | sed 's/\\r//g'`