Concatenate outputs of the commands

Viewed 18

Can someone please help me to concatenate the outputs of the two commands?

finger | awk '{print $2,$3}' | uniq | sed '1d'

system_profiler SPHardwareDataType | awk '/Serial/{print $NF}'

The output should be firstnamelastname.Serialnumber.local

1 Answers

you can affect result of two commands in variables to be able to concatenate them in a result one

first=$(finger | awk '{print $2,$3}' | uniq | sed '1d')
second=$(system_profiler SPHardwareDataType | awk '/Serial/{print $NF}')
result="$first.$second"
echo $result;
Related