Bash - Concatenating Variable on to Path

前端 未结 1 1888
粉色の甜心
粉色の甜心 2021-01-22 18:35

Currently, I have a bash script that will untar a file in my root directory:

#!/bin/bash
tar xvf ~/some-file.tar

This works without problems. N

相关标签:
1条回答
  • 2021-01-22 19:38

    Tilde expansion doesn't work when inside a variable. You can use the $HOME variable instead:

    #!/bin/bash
    p=$HOME
    tar xvf "$p/some_file.tar"
    
    0 讨论(0)
提交回复
热议问题