Книга: 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

Оглавление книги


Генерация: 1.583. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз