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

StackOverflow https://stackoverflow.com/questions/11322302

Question

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.

Était-ce utile?

La solution

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top