3
请看看下面的命令:的Linux命令shell命令行奇怪的行为
[email protected]:~/usp$ cat file
c
b
a
[email protected]:~/usp$ x="cat file | sort"
[email protected]:~/usp$ $x
c
b
a
cat: |: 没有那个文件或目录
cat: sort: 没有那个文件或目录
我的问题是,为什么$ x的输出不是:
a
b
c
剂量双引号改变命令行为cat file | sort
?
这确实是什么错误消息说(没有这样的文件或目录)。 – EOL 2013-05-05 15:44:01
谢谢@Mat和@EOL。我希望在'until'命令中使用一个变量,例如'until $ var'来减少代码行,因为在不同情况下,'until'命令语句会有所不同。在其中一种情况下,我需要执行像'var =“command1 | command2”'这样的任务。现在它不起作用。有没有解决这个问题的另一种方法? – 2013-05-05 16:02:43
@ Wenhao Yang:你应该为此提出一个新问题,但一定要包括足够的细节,因为这看起来有点奇怪。你不能使用函数而不是变量吗? – Mat 2013-05-05 16:08:24