The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 06:15 AM
previous,next command in unix arulkumar UNIX for Dummies Questions & Answers 4 09-11-2007 07:34 AM
Previous Command vskr72 UNIX for Dummies Questions & Answers 2 04-20-2007 11:03 AM
Seeing previous command JackieChan UNIX for Dummies Questions & Answers 4 06-02-2006 09:35 AM
Repeat a command in a shell scotty UNIX for Dummies Questions & Answers 2 10-30-2002 02:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 3.00 average. Display Modes
  #1 (permalink)  
Old 07-07-2008
syang68 syang68 is offline
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!
  #2 (permalink)  
Old 07-07-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,546
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...
  #3 (permalink)  
Old 07-07-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,546
If its executing the last command XXX again,
Then just type:
r XXX (with ksh...)
  #4 (permalink)  
Old 07-07-2008
spirtle spirtle is offline
Registered User
  
 

Join Date: Jun 2008
Location: Scotland
Posts: 150
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.
  #5 (permalink)  
Old 07-07-2008
syang68 syang68 is offline
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!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0