What are the ways to replace Shell commands?
This article introduces the relevant knowledge of "what are the ways to replace Shell commands?". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Command replacement (command substitution) means that Shell executes a command and replaces the command replacement portion with the result of executing the command.
There are two ways to replace commands:
1. Use backtick symbols (I. e., backquotes, accents).
The code is as follows:
For i in `cd / old/code/dir; echo * .c`
Do
Diff-c / old/code/dir/$i $I | more
Done
two。 Use $(…) The way.
The code is as follows:
For i in $(cd / old/code/dir; echo * .c)
Do
Diff-c / old/code/dir/$i $I
Done | more
Note: when using the first method, both embedded backtick symbols and double quotes need to be escaped. In the second way, embedded parentheses do not need to be escaped.
This is the end of the content of "what are the ways to replace Shell commands". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!