How can I insert a tab character with sed on OS X?

后端 未结 6 1501
野的像风
野的像风 2020-11-29 23:20

I have tried:

echo -e \"egg\\t  \\t\\t salad\" | sed -E \'s/[[:blank:]]+/\\t/g\'

Which results in:

eggtsalad
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 00:14

    Another option is to use $(printf '\t') to insert a tab, e.g.:

    echo -e "egg\t  \t\t salad" | sed -E "s/[[:blank:]]+/$(printf '\t')/g"
    

提交回复
热议问题