samedi 7 mars 2015

command substition for multiline output of command?


How can I make the following command substitution work?



$ time

real 0m0.000s
user 0m0.000s
sys 0m0.000s

$ oldtime="$(time)"
bash: command substitution: line 23: syntax error near unexpected token `)'
bash: command substitution: line 23: `time)"'


I guess it doesn't work because the output of the command has multiple lines, because one line output works:



$ oldtime="$(echo hello)"
$ echo $oldtime
hello


Aucun commentaire:

Enregistrer un commentaire