Рейтинг@Mail.ru
[Войти] [Зарегистрироваться]

Наши друзья и партнеры

UnixForum


Lines Club

Ищем достойных соперников.




Книги по Linux (с отзывами читателей)

Библиотека сайта или "Мой Linux Documentation Project"

6.3. Command Substitution

Command substitution is basically another way to do a pipe, you can use pipes and command substitution interchangeably, it's up to you which one you find easier...

Command substitution can be done in two distinct ways.

Method═One═(back-quotes)

Simply type:

command_1 `command_2 -options`

This will execute “command_2” and it's output will become the input to “command_1”.

TipBackquote key
 

The back-quote key is usually located at the same place as the tilde, above the [Tab] key.

Method═Two═(dollars═sign)

Simply type:

command_1 $(command_2)

This will execute “command_2” and it's output will become the input to “command_1”.

Using═the═pipe═instead

You can of course use pipes to do the same thing, if you don't know what a pipe is, please see Section 6.2. For example instead of doing:

less $cat file1.txt file2.txt

You could do:

cat file1.txt file2.txt | less

And end up with exactly the same result, it's up to you which way you find easier.


Эта статья еще не оценивалась
Вы сможете оценить статью и оставить комментарий, если войдете или зарегистрируетесь.
Только зарегистрированные пользователи могут оценивать и комментировать статьи.

Комментарии отсутствуют