The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Repeat last entered command ? vilius Shell Programming and Scripting 5 09-25-2007 03:15 AM
previous,next command in unix arulkumar UNIX for Dummies Questions & Answers 4 09-11-2007 04:34 AM
Previous Command vskr72 UNIX for Dummies Questions & Answers 2 04-20-2007 08:03 AM
Seeing previous command JackieChan UNIX for Dummies Questions & Answers 4 06-02-2006 06:35 AM
Repeat a command in a shell scotty UNIX for Dummies Questions & Answers 2 10-29-2002 11:42 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-07-2008
Registered User
 

Join Date: Jun 2008
Posts: 9
Repeat previous unix command

Hi all,

Is there a way to bring back the previous unix command without retyping?

I tried the "arror up" key, and it seems not working (sun solaris). What is the correct way?

Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 07-07-2008
vbe vbe is offline
Moderator
 

Join Date: Sep 2005
Location: Switzerland
Posts: 775
Depends what shell you are using...
e.g. for Solaris
if you use /usr/bin/ksh:

# set -o vi (if not done yet as EDITOR=... in .profile...)
then its Esc+ k (backward...) j (Forward)
This works because you have a history file set...
Reply With Quote
  #3  
Old 07-07-2008
vbe vbe is offline
Moderator
 

Join Date: Sep 2005
Location: Switzerland
Posts: 775
If its executing the last command XXX again,
Then just type:
r XXX (with ksh...)
Reply With Quote
  #4  
Old 07-07-2008
Registered User
 

Join Date: Jun 2008
Location: Scotland
Posts: 121
In tcsh (and bash?) you can use

!! to execute the previous command again,
!-n to execute again the nth to last command
!foo to execute again the last command beginning with the string foo
!?foo to execute again the last command containing the string foo

Append
Code:
:p
to display rather than execute the command.
Reply With Quote
  #5  
Old 07-07-2008
Registered User
 

Join Date: Jun 2008
Posts: 9
Repeat previous unix command

Thanks for your reply. I am using ksh.

In linux, if my last command is for example "ls -ltr |tail", I just hit the "arrow up " key to bring it (ls -ltr |tail) back on the command line and then verify it. This gives me the opportunity to display the command before executing it.

The command 'r' that vbe suggests is good, but it is executed before I even have the opportunity to dsplay it.

I need a command (or key stroke) in order to display and then repeat the execution without retyping the command. Any idea?

Thanks!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0