问题
I'm not a "command line" person by any means. I have been a front-end dev my entire career with little to no interaction with the command line, instead utilizing application GUIs as much as possible, so this may be a rather rudimentary question to many of you.
I ran into a small issue when trying to commit with Git. I included the -m
message flag and tried a message similar to "Example add function" with the word "add" surrounded by ` backtick symbols (can't show it here since doing that displays the word as code and I don't know how to escape it in this editor).
I got the error: -bash: add: command not found
I've used the backtick to surround function names many times in the past with Git with no problems. I assume there's some sort of reserved keyword here with either Git specifically or just the command line in Linux in general, but I'd like to know what the specific situation is so I can understand how to avoid it in the future.
Thanks.
回答1:
Bash takes the content of the backticks and runs another bash process with that as a command.
Another (prefered) way is $( ... )
.
To include backticks, use single quotes for your string, not " but '.
回答2:
Also, this syntax substitute stdout of another process,not just run it.
来源:https://stackoverflow.com/questions/11322302/what-does-the-backtick-do-in-a-command-line-invocation-specifically-with-r