What does the backtick - ` - do in a command line invocation specifically with regards to Git commands?

…衆ロ難τιáo~ 提交于 2019-12-24 20:14:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!