Can I execute nested or chained commands in a UNIX shell?

Is it possible to execute a command on another command in UNIX shells?

If this is not possible, can I use the output of the previous command as the input of the next command, as in:

command xThen command y,

where in command yI want to use the output command x?

+3
source share
3 answers

? , . , , , . ( ), "find", Colin , "-exec" "find". , stdin, "xargs". , "$ (command)" ( "command" [ "backquote]) . , , , , .

+3

.

, cat.txt

cat & grave; echo file.txt & grave;

, ;

.

+8

You can do something like:

x=$(grep $(dirname "$path") file)

here it dirname "$path"will be launched first, and its result will be replaced, and then grep will be launched, looking for the result dirnameinfile

+6
source

Source: https://habr.com/ru/post/1765512/


All Articles