Jojo John
Jojo John

Reputation: 400

Combine two linux command to show as single string

I am having two commands

hostname -f and cat /sys/block/sda/size

Need to combined output like hostname:34345

I tried using

hostname -f && cat /sys/block/sda/size

But output is printing in two lines. Please help me to get the output as required

Upvotes: 1

Views: 70

Answers (1)

hek2mgl
hek2mgl

Reputation: 157947

Assuming that you are using the bash shell, you can use command substitution:

echo "$(hostname):$(cat /sys/block/sda/size)"

Upvotes: 2

Related Questions