shiwenlu518
shiwenlu518

Reputation: 466

How to print the previous linux command's output?

The problem is:

After user enter a linux command.

How can I get the output of the first command using another command?

Note: we cannot redirect output of first command to somewhere.

Upvotes: 1

Views: 3437

Answers (1)

glenn jackman
glenn jackman

Reputation: 246807

Using history expansion

$ date -d "12:00"
Thu Sep 19 12:00:00 EDT 2013
$ d=$(!!)
$ echo $d
Thu Sep 19 12:00:00 EDT 2013

Upvotes: 3

Related Questions