Unix command to escape spaces

后端 未结 7 1431
春和景丽
春和景丽 2020-12-14 07:21

I am new to shell script. Can someone help me with command to escape the space with \"\\ \". I have a variable FILE_PATH=/path/to my/text file ,
I want to escape the spa

7条回答
  •  青春惊慌失措
    2020-12-14 07:44

    Use quotes to preserve the SPACE character

    tr is used only for replacing individual characters 1 for 1. Seems to be that you need sed.

    echo $FILE_PATH | sed -e 's/ /\\ /'
    

    seems to do what you want.

提交回复
热议问题