bashreplace

Replace tab with space using Bash parameter substitution


How can I use ${var//Pattern/Replacement} to replace tab with space?

${var//\t/ } doesn't work for me.


Solution

  • You need to type an actual TAB character:

    var=${var// / }
               ^ that's really meant to be a TAB character
                 but might not be visible on this site
    

    On the command line, to insert a TAB character, press ControlvTAB.