Output multiple Linux commands into columns

Posted on July 12, 2020 at 9:51 pm

You can run multiple Linux commands and get the output for each command delimited by a column:

paste -d'|' <(echo "$VAR1") <(echo "$VAR2") <(echo "$VAR3") <(echo "$VAR4")

You can also run commands “inline” inside $(), example:

paste -d'|' <(echo $(pwd)) <(echo $(id))

Here is the example output:

/root|uid=0(root) gid=0(root) groups=0(root)

As you see each command output is separated by “|”.

As specified in the paste -d command.

Looks like that commands are executed in parallel, you can test it:

paste -d'|' <(echo $(sleep 1)) <(echo $(sleep 1)) <(echo $(sleep 1)) <(echo $(sleep 1)) <(echo $(sleep 1))

Instead of taking 5 seconds it takes 1 second.

Receive updates via email

Other Posts

Updated Posts