I have command, which output two columns. For example:
undefine@uml:~$ uptime -s
2015-10-26 08:47:12
How can i put this two columns into separate variables? I would like to do something like:
undefine@uml:~$ uptime -s | read day hour
undefine@uml:~$ echo $day
undefine@aml:~$
I know, that in bash i can execute it like:
undefine@uml:~$ read day hour <<< $(uptime -s)
undefine@uml:~$ echo $day
2015-10-26
I can also redirect output from uptime to file, and then read from that file:
undefine@uml:~$ uptime -s > tmpfile
undefine@uml:~$ read day hour < tmpfile
undefine@uml:~$ echo $day
2015-10-26
But how to do it "posix sh way", and without creating any temporary files?