How to recall an old command at the command prompt?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
How to recall an old command at the command prompt?
I know how to step through the command history at the command prompt, but is it also possible to search for and recall a command that was issued a long time before (supposed that it is still in the history)?
From time to time I wish there was one, but I could not find the clue in the bash manual.
Thanks in advance.
This will spit back the last 1000 commands you have issued. Well for bash it is 1000 by default but you can change it. Each command will have a number before it. Heres an example of one of the things you will get back from the history command:
1057 mount -t iso9660 /dev/scd0 /mnt/cdrom
Now if you want to run that command again just do:
!1057
A very cool feature I think.
Last edited by Crashed_Again; 02-26-2003 at 12:42 AM.
Definitely, I'm a big fan of the shebang-history command. Also, if you have a terminal in which the up-arrow doesn't recall your last command, hitting !! repeats the last command.
Good for compile-edit cycles, too:
$ vi prog.c
$ gcc prog.c
(errors)
$ !v
(edit in vi, then exit)
$ !g
(more errors)
you could also use the bang command as a search/recall automatically....instead of grepping history, if you know you want the last mount command (which may have been a long time ago)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.