trigone
October 22nd, 2015, 05:10 PM
hi,
i observed the following bash output:
>>> a=~/foo; [ -f $a ]; echo $?
0
>>> a="~/foo"; [ -f $a ]; echo $?
1
>>> a=~/foo; [ -f "$a" ]; echo $?
0
>>> a="~/foo"; [ -f "$a" ]; echo $?
1
my question is: in the case of files with whitespace in the name, is there a (simple) way to put its path in a variable, using the tilde, and making tests, readlink, etc, accept them as actual paths, and not, apparently, items inside /current/working/dir/~/. of course i suppose that individual escaping of whitespace with counterslash could work, but i wonder if there's an other way.
thanks in advance :)
i observed the following bash output:
>>> a=~/foo; [ -f $a ]; echo $?
0
>>> a="~/foo"; [ -f $a ]; echo $?
1
>>> a=~/foo; [ -f "$a" ]; echo $?
0
>>> a="~/foo"; [ -f "$a" ]; echo $?
1
my question is: in the case of files with whitespace in the name, is there a (simple) way to put its path in a variable, using the tilde, and making tests, readlink, etc, accept them as actual paths, and not, apparently, items inside /current/working/dir/~/. of course i suppose that individual escaping of whitespace with counterslash could work, but i wonder if there's an other way.
thanks in advance :)