Книги автора: Fedora™ Unleashed, 2008 edition
/ Книги автора: Fedora™ Unleashed, 2008 edition
/ honorato bonafe
Книга: Fedora™ Unleashed, 2008 edition
Using the Backtick to Replace a String with Output
Using the Backtick to Replace a String with Output
You can use the backtick (`
) character to signal the shell to replace a string with its output when executed. This special character can be used in shell programs when you want the result of the execution of a command to be stored in a variable. For example, if you want to count the number of lines in a file called test.txt
in the current directory and store the result in a variable called var
, you can use the following command:
Command | Environment |
---|---|
var=`wc -l test.txt` |
bash |
set var = `wc -l test.txt` |
tcsh |
Похожие страницы
- Using Single Quotes to Maintain Unexpanded Variables
- 4.4.4 The Dispatcher
- About the author
- Chapter 7. The state machine
- Appendix E. Other resources and links
- Caveats using NAT
- Example NAT machine in theory
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces
- The final stage of our NAT machine
- Compiling the user-land applications
- The conntrack entries
- Untracked connections and the raw table