linux - Bash - Concatenating Variable on to Path -
currently, have bash script untar file in root directory:
#!/bin/bash tar xvf ~/some-file.tar
this works without problems. now, change can specify path file in pre-defined variable such:
#!/bin/bash p="~" tar xvf $p/some-file.tar
this gives me following error message:
tar: ~/some-file.tar: cannot open: no such file or directory tar: error not recoverable: exiting
the path file seems correct, however, there hidden characters causing fail? proper way concatenate variable , path without storing both in string variables (if there one)?
tilde expansion doesn't work when inside variable. can use $home
variable instead:
#!/bin/bash p=$home tar xvf "$p/some_file.tar"
Comments
Post a Comment