Reputation: 348
I have this function:
test() {
echo "$1"
}
$1
can receive an argument. This works:
test "i am here"
i am here
Now I want to receive the result of date
.
date
Tue Jan 10 10:36:10 CST 2017
test `date`
Tue
How to make Jan 10 10:36:10 CST 2017 not be omitted?
Upvotes: 0
Views: 38
Reputation: 42989
You need to enclose the result of date
in double quotes for the entire date string to be sent as a single argument to your function:
test "`date`"
or, more preferably:
test "$(date)"
Here is an example:
$ test "$(date)"
Tue Jan 10 03:17:26 UTC 2017
Upvotes: 2