Why is sed not recognizing \t as a tab?

前端 未结 11 1588
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 19:54
sed \"s/\\(.*\\)/\\t\\1/\" $filename > $sedTmpFile && mv $sedTmpFile $filename

I am expecting this sed script to insert a <

11条回答
  •  一向
    一向 (楼主)
    2020-11-29 20:32

    Using Bash you may insert a TAB character programmatically like so:

    TAB=$'\t' 
    echo 'line' | sed "s/.*/${TAB}&/g" 
    echo 'line' | sed 's/.*/'"${TAB}"'&/g'   # use of Bash string concatenation
    

提交回复
热议问题