user983223
user983223

Reputation: 1154

put output into a variable

The following works if I type it in a shell window. But how do I get the result into a variable?

date -j -v+1m -f "%a %b %d %T %Z %Y" "`date`" "+%s"

Upvotes: -1

Views: 167

Answers (1)

jaypal singh
jaypal singh

Reputation: 77075

You can use command substitution $(..) and capture the output in a variable

var=$(date -j -v+1m -f "%a %b %d %T %Z %Y" "`date`" "+%s")
echo $var

Note: Not tested and as stated in the comments, the syntax may vary.

Upvotes: 2

Related Questions