LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 06-29-2005, 04:56 PM   #1
belorion
Member
 
Registered: Aug 2003
Distribution: Slackware 10.0
Posts: 124

Rep: Reputation: 16
!(last command) trick?


I know that

$>!#

Executes the command found at # in your history and

$>!ba

Would execute the last command that starts with "ba", and that

$>ping !$

Would execute the ping with the argument from the last command, but is there a way to expand what the command is? IE, I want to be able to type

$>!pi (and some key combo)

That will expand the command to

$>ping -n 10 foo.com

So I can see the command before I execute it. Is this possible?
 
Old 06-29-2005, 06:12 PM   #2
mhallbiai
Member
 
Registered: Jun 2005
Posts: 96

Rep: Reputation: 15
i think you are looking for
Code:
]$
]$ !:p
 man bash
]$ !pin:p
 ping -n 10 foo.com
]$
hope this helps

[EDIT: corrected :p from being smiley]

Last edited by mhallbiai; 06-29-2005 at 06:19 PM.
 
Old 06-29-2005, 07:09 PM   #3
pbhj
Member
 
Registered: Dec 2002
Location: UK
Distribution: Slackware 12; Ubuntu 7.10
Posts: 358

Rep: Reputation: 31
where did you learn this?

How do you find the man page for ! or :

!?
 
Old 06-30-2005, 08:07 PM   #4
mhallbiai
Member
 
Registered: Jun 2005
Posts: 96

Rep: Reputation: 15
pbhj,

! is an event designator used in history expansion for bash.
there is a wealth of documentation for bash.
that just scratched the surface...
Code:
man bash
you can search the man pages for 'event designators' and it will bring you directly to ! paging up from there will explain HISTORY EXPANSION

: is a under SHELL BUILTIN COMMANDS discussed after !

hope this helps

many happy hours of reading

[EDIT: cleaned up spacing]

Last edited by mhallbiai; 06-30-2005 at 08:09 PM.
 
Old 07-02-2005, 02:00 PM   #5
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
You could also try Ctrl+r, which gives you a reverse search. For example, you do ping -n 10 foo.com

So, the next time you need to ping foo.com, you can type ctrl+r and then write pi and it would auto complete.
 
Old 07-03-2005, 01:01 PM   #6
thrombomodulin
LQ Newbie
 
Registered: Dec 2003
Location: MI, USA
Distribution: FC 2
Posts: 14

Rep: Reputation: 0
vi-keys

set -o vi
(or bindkey -v in tcsh)

will bind the keys on the command line to be like the vi editor, you can search backwards for a command and edit it, then execute it.

Regards,.
T
 
  


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
old command line email trick LinuxLala Linux - General 4 03-11-2004 11:56 PM
a trick id like to learn czarherr Linux - Software 7 03-03-2004 05:05 AM
2 problem trick felipe_ced Linux - Newbie 1 08-20-2003 10:57 AM
How to trick a router Citizen Bleys Linux - Networking 4 01-31-2002 01:09 PM
Awesome X trick doodah Linux - General 6 06-01-2001 07:51 AM


All times are GMT -5. The time now is 08:23 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration