I am having some trouble with a script to change the computer name to First Last Computer Model. Here is what I currently have and it is only changing it to First Last. Any help would be appreciated. Here is what I have currently.
#!/bin/sh
#gets current logged in user
getUser=$(ls -l /dev/console | awk '{ print $3 }')
#gets model name
model=$(/usr/sbin/ioreg -rd1 -c IOPlatformExpertDevice | /usr/bin/awk -F { print $2 } | /usr/bin/sed 's/[0-9]*//g')
#gets named
firstName=$(finger -s $getUser | head -2 | tail -n 1 | awk '{print toupper($2)}')
lastName=$(finger -s $getUser | head -2 | tail -n 1 | awk '{print toupper($3)}')
computerName="$firstName $lastName $Model"
#set all the name in all the places
scutil --set ComputerName "$computerName"
scutil --set LocalHostName "$computerName"
scutil --set HostName "$computerName"