7/21/2008

Copy the last used command in linux comand prompt

How do i copy the last used command in linux comand prompt?

use echo to print
echo !!

use redirection to dump to file
echo !! > last_command.txt

use two greater-thans to append a file
echo !! >> command_list.txt

copying to an environment variable depends on your shell. in csh, it'd be
setenv MYCOMMAND !!

but in bash it'd be something like
export MYCOMMAND=!!

0 comments: