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

前端 未结 2 1760
野的像风
野的像风 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 06:56

    You have an extra space there, it's simply

    "$NEWAPP"

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题