怎么理解ls `ls`这个命令?
发表于 : 2008-11-20 22:49
在终端下执行 ls `ls`(那个 ` 是键盘上方的数字鍵 1 左边那个按键,而不是单引号!)
输出结果第一行报错,但从第二行开始显示了当前目录下的所有文件(子文件夹中的文件也被递归的显示出来了)
不明白为什么会产生这个结果?
输出结果第一行报错,但从第二行开始显示了当前目录下的所有文件(子文件夹中的文件也被递归的显示出来了)
不明白为什么会产生这个结果?

恩,谢谢了,文件命后面跟了个空格,所以报了错。文件名不能有空格吗?xhy 写了:有文件名中间带IFS了 通常是个空格
刚才测试发现如果从终端取得的输入对于a命令毫无意义的话,整个命令a | b还是可以运行成功,不过效果就相当于只执行b命令了。如exit | lsxhy 写了:a | b a命令的结果通过管道传递给b,并不是作为参数,效果相当于b运行后从终端取得输入
请问这个$*怎么解释?goomoott2 写了:想将ls的返回结果给ls做参数的话,可以这样做
代码: 全选
ls | xargs ls $*
Dic4000 写了:请问这个$*怎么解释?goomoott2 写了:想将ls的返回结果给ls做参数的话,可以这样做
代码: 全选
ls | xargs ls $*
代码: 全选
Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, it
expands to a single word with the value of each parameter separated by the first character of the IFS special
variable. That is, "$*" is equivalent to "$1c$2c...", where c is the first character of the value of the IFS
variable. If IFS is unset, the parameters are separated by spaces. If IFS is null, the parameters are joined
without intervening separators.
代码: 全选
ls | xargs ls