Skip to main content
2 of 2
explain what the command actually does.
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Assuming history expansion is enabled, that you're running Bash or some other shell that supports it, that the command is idempotent, and that waiting for it to run a second time is not an issue, you could use the !! form of history expansion to get the last command line again, to run the previous command again in a command substitution:

% python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/usr/lib/python2.7/site-packages
% cd $(!!)
cd $(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
% pwd
/usr/lib/python2.7/site-packages
jsbillings
  • 24.9k
  • 7
  • 58
  • 58