tabssedcode-formattingblank-line

How to remove tabs from blank lines using sed?


I'd like to use sed to remove tabs from otherwise blank lines. For example a line containing only \t\n should change to \n. What's the syntax for this?


Solution

  • sed does not know about escape sequences like \t. So you will have to literally type a tab on your console:

    sed 's/^    *$//g' <filename>
    

    If you are on bash, then you can't type tab on the console. You will have to do ^V and then press tab. (Ctrl-V and then tab) to print a literal tab.