有个命令:
printf '%s\t %s\t %s\t %s\t %s\t \n' $(cat test.txt)
最后的$(cat test.txt)是什么意思?
$(命令),有这样的用法吗?
请教$(cat test.txt)的意思和用法?
- azazazaz
- 帖子: 37
- 注册时间: 2008-11-28 13:29
- lxr1234
- 帖子: 721
- 注册时间: 2009-04-10 11:15
- 来自: 三民主义国国民权利省我的选择市中共下台镇
Re: 请教$(cat test.txt)的意思和用法?
没错,就是执行这个命令,不然中间的空格成了分割符
强烈反对M$的ARM Secure Boot 锁定要求,大家请签名反对
http://www.fsf.org/campaigns/secure-boo ... cted-boot/
http://www.fsf.org/campaigns/secure-boo ... cted-boot/
- azazazaz
- 帖子: 37
- 注册时间: 2008-11-28 13:29
Re: 请教$(cat test.txt)的意思和用法?
$(命令)这是什么用法?有详细点的说明吗?
-
- 帖子: 21
- 注册时间: 2010-07-09 17:12
Re: 请教$(cat test.txt)的意思和用法?
就是把这条命令的执行结果放在这里。跟``有点像,不过``会在整条语句执行前先执行,而$()会到这个地方的时候再执行。
- azazazaz
- 帖子: 37
- 注册时间: 2008-11-28 13:29
Re: 请教$(cat test.txt)的意思和用法?
明白了,多谢上面两位朋友。
- naturalaw
- 帖子: 1360
- 注册时间: 2011-09-06 22:04
Re: 请教$(cat test.txt)的意思和用法?
``和$()的差异在于转义和可移植性,而不是引用中所说的。514617335 写了:就是把这条命令的执行结果放在这里。跟``有点像,不过``会在整条语句执行前先执行,而$()会到这个地方的时候再执行。
``在多层使用时,要使用转义;$()无需。``的移植性较$()好。
参考shell 13问。
- 永恒之法则
- The eternal law
-
- 帖子: 6548
- 注册时间: 2008-10-31 22:12
- 系统: 践兔
- 联系:
Re: 请教$(cat test.txt)的意思和用法?
代码: 全选
Command Substitution
Command substitution allows the output of a command to replace the command
name. There are two forms:
$(command)
or
`command`
Bash performs the expansion by executing command and replacing the command
substitution with the standard output of the command, with any trailing
newlines deleted. Embedded newlines are not deleted, but they may be
removed during word splitting. The command substitution $(cat file) can be
replaced by the equivalent but faster $(< file).
When the old-style backquote form of substitution is used, backslash
retains its literal meaning except when followed by $, `, or \. The first
backquote not preceded by a backslash terminates the command substitution.
When using the $(command) form, all characters between the parentheses make
up the command; none are treated specially.
Command substitutions may be nested. To nest when using the backquoted
form, escape the inner backquotes with backslashes.
If the substitution appears within double quotes, word splitting and path‐
name expansion are not performed on the results.
代码: 全选
] ls -ld //
- 13378333
- 帖子: 322
- 注册时间: 2012-05-31 12:00
Re: 请教$(cat test.txt)的意思和用法?
%s 是神马意思?lxr1234 写了:没错,就是执行这个命令,不然中间的空格成了分割符