1

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.

shiwenlu518
  • 446
  • 3
  • 7
  • What are you trying to do ? Are you looking for `output=$(command)` ? – cnicutar Sep 18 '13 at 10:59
  • possible duplicate of [bash - automatically capture output of last executed command into a variable](http://stackoverflow.com/questions/5955577/bash-automatically-capture-output-of-last-executed-command-into-a-variable) – devnull Sep 18 '13 at 11:10
  • You seem to be looking for [this](http://stackoverflow.com/a/6052267/2235132) solution. – devnull Sep 18 '13 at 11:10

1 Answers1

3

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
glenn jackman
  • 238,783
  • 38
  • 220
  • 352