- 论坛徽章:
- 2
|
- 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).
复制代码 执行``的时候,会把里面的换行用空格替换掉。- yu@yu-vm:~/0513$ awk '{print $1}' 1.txt
- a
- b
- c
- d
- a
- b
- a
- c
- yu@yu-vm:~/0513$ echo `awk '{print $1}' 1.txt`
- a b c d a b a c
- yu@yu-vm:~/0513$ echo "`awk '{print $1}' 1.txt`"
- a
- b
- c
- d
- a
- b
- a
- c
- yu@yu-vm:~/0513$
复制代码 至于ls为啥单独执行的时候不会换行,这个man ls也没查到。期待大神来解答下
|
|