首页 > shell的touch命令不能拼接路径吗?

shell的touch命令不能拼接路径吗?

touch $path$x"/"$txt1,结果只能执行到"/"之前


export mypath=/tmp
export subpath=/1
echo "$mypath$subpath/filename.txt"

可以啊:

[root@iZ11eorublsZ tmp]# x=a
[root@iZ11eorublsZ tmp]# y=b
[root@iZ11eorublsZ tmp]# touch $x"/"$y
touch: cannot touch `a/b': No such file or directory
[root@iZ11eorublsZ tmp]# mkdir a
[root@iZ11eorublsZ tmp]# touch $x"/"$y
[root@iZ11eorublsZ tmp]# ll a/b
-rw-r--r-- 1 root root 0 Aug  5 13:11 a/b

把你的几个变量值也同时给出来,包括你执行的结果

【热门文章】
【热门文章】