m19v Asked: 2020-01-31 07:48:11 +0800 CST2020-01-31 07:48:11 +0800 CST 2020-01-31 07:48:11 +0800 CST Combine two command defined as String in variable and run as one 772 Can I join two commands defined as String and run as one. E.g. var=$(ls -alt) var2="| grep usersfile" '{$var & $var2;}' command-line bash join 1 Answers Voted Vishnu Suresh 2020-02-10T06:30:44+08:002020-02-10T06:30:44+08:00 you can use the & operator to combine two commands. example: mkdir folder & cd folder But in case you want to give the first commands output as input to the second command, you can always trust the pipeline | example: ls -l | grep <keyword>
you can use the
&
operator to combine two commands.example:
But in case you want to give the first commands output as input to the second command, you can always trust the pipeline
|
example: