Unix command to escape spaces

后端 未结 7 1434
春和景丽
春和景丽 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 08:03

    You can do it with sed :

    NEW_FILE_PATH="$(echo $FILE_PATH | sed 's/ /\\ /g')"
    

提交回复
热议问题