LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-22-2008, 07:39 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
The "History" Command?


I recall my old work colleague show me a history command that allows you to search the history for all commands that started with lets say "wget" or whatever you're looking for rather than everything in your history cache. I attempted a Google search and could not find anything that shows me how to refine the history search.

Anyone know what I am looking for?
 
Old 01-22-2008, 07:44 PM   #2
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,421
Blog Entries: 7

Rep: Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535Reputation: 2535
grep?

It works like this:

cat ~/.bash_history | grep wget
 
Old 01-22-2008, 07:50 PM   #3
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Quote:
Originally Posted by rkelsen View Post
grep?

It works like this:

cat ~/.bash_history | grep wget
Thanks - that does the trick however I recall there being a command with in the history command that allows you to do the same thing w/o using "grep"

Either way, it appears the results are the same...
 
Old 01-22-2008, 08:08 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
You also might check out the event designator "!", which lets you quickly print (with or without executing) the most recent command that starts with a certain string.

Contrived example:
Code:
[fugu ~]$ history 
   11  file /etc/sysconfig/iptables
   12  ls
   13  top
   14  history 
[fugu ~]$ !file:p
file /etc/sysconfig/iptables
The :p modifier tells bash to print but not execute the command.

In any case, that still doesn't sound like quite what you're looking for; check out the extensive manpages for bash(1). There's a good sized section on history and related topics there.
 
Old 01-29-2008, 01:09 AM   #5
smehra24
Member
 
Registered: Jan 2008
Location: mumbai
Distribution: red hat
Posts: 31

Rep: Reputation: 15
Use CTRL+R

Use the above combination of the keys to search for a string.. very helpful indeed.
 
Old 01-29-2008, 03:14 AM   #6
ComputerGreek
Member
 
Registered: Sep 2007
Posts: 152

Rep: Reputation: 30
I see smehra24 has already answered.

Just use EMACS commands.

What you want is

Code:
Ctrl-R wget
Ctrl-R is the usual EMACS reverse search command.

Look in "info bash" for more info.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
clear history "last" command nistelrooy Linux - Newbie 10 11-03-2010 12:09 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Command Line "History" mcupples Linux - Server 2 04-05-2007 03:32 PM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 03:28 PM
How to find back "history" database after "history -c" ? san_lss Linux - Newbie 1 01-07-2004 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration