How do I use a variable containing a filename with spaces in a bash script?

前端 未结 2 1800
野的像风
野的像风 2021-01-23 06:33

I have a simple bash script running on OS X that removes specific files and directories and copies new ones in their place. One Mac .app directory contains a space, and when I

2条回答
  •  忘了有多久
    2021-01-23 07:07

    enclose the whole final line in quotes:

    "$CP $NEWAPP $INSTALL_DIR$NEWAPP"
    

    it's unnecessary to keep opening and closing the quotes here, and the $CP must be contained in quotes as CP has a space in it.

提交回复
热议问题