Set environment variable with space in Linux

前端 未结 3 826
一向
一向 2020-12-15 03:13

I want to set an environment variable that has space in it. it is a path to a folder and the folder name is: /home/mehrabib/my video

I edit .bashrc and add the follo

相关标签:
3条回答
  • 2020-12-15 03:35

    You can also substitute special characters - use * as a wildcard to substitute for the space.

    VIDEO="/home/mehrabib/m*o"

    0 讨论(0)
  • 2020-12-15 03:44

    Try to quote VIDEO: cd "$VIDEO".

    0 讨论(0)
  • 2020-12-15 03:46

    You should do

    export VIDEO="/home/mehrabib/my video"
    

    and to sum Dan's comments up also do

    cd "$VIDEO"
    

    which will expand to

    cd "/home/mehrabib/my video"
    

    again.

    Personally, I've come to prefer the ${VIDEO} syntax.

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