What does the backtick - ` - do in a command line

2019-09-05 01:30发布

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.

2条回答
太酷不给撩
2楼-- · 2019-09-05 02:12

Also, this syntax substitute stdout of another process,not just run it.

查看更多
相关推荐>>
3楼-- · 2019-09-05 02:17

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 '.

查看更多
登录 后发表回答