본문 바로가기

Research/Linux

명령어 치환. Command substitution



더블 쿼터는 쉘 메타캐릭터 문자(와일드카드 같은 것)을 막지 않음.




Command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed as follows:


$(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 filename expansion are not performed on the results.

'Research > Linux' 카테고리의 다른 글

When sidebar(unity) disappeared in Ubuntu  (0) 2016.05.31
root ssh 접속 차단  (0) 2015.08.04
socat / xinetd  (0) 2015.05.06
x64 syscall function table  (0) 2015.01.08
ARMv8 Qemu Install Reference  (0) 2014.11.11