Reputation: 1
I want to run two linux commands such as :
whoami && stat -c %i "/home"
But I want the result to be
user 123456
(all on one line without a break in the line).
Upvotes: 0
Views: 255
Reputation: 84561
If using bash (or any other shell that supports arrays), you can use an array as well. Simply store the output from your original compound command in an array using command substitution:
$ var=( $(whoami && stat -c %i "/home") ); echo "var '${var[@]}'"
var 'david 2'
Upvotes: 1
Reputation: 6214
Try capturing the results of both of your commands and using something else to format them into a single line. This should do the trick:
echo `whoami` `stat -c %i "/home"`
Upvotes: 1