How to retrieve the typed command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to retrieve the typed command
# 1  
Old 07-14-2005
How to retrieve the typed command

For examples, I have typed 4 commands in the command prompt:
ls -la
rm -rf /home/user1
du -k /home
find . -name "abc.out" -print


And now I want to retrieve the command which begin with letter "r" (i.e. rm -rf /home/user1), what can I do?
# 2  
Old 07-14-2005
with bash : ctrl-r
# 3  
Old 07-14-2005
thx,
How about korn shell?
# 4  
Old 07-14-2005
first do a "set -o vi"

then press ESC

type /r then ENTER

it will give you the last command typed starting with "r"

if you don't want that command then type "k" it will give you the second last command starting with "r" .....and so on...


The point is even at the command line it behaves as if you opened a file and looking for a someting starting with "r"

Hope this helps,
Jingi
# 5  
Old 07-15-2005
MySQL

once you have your shell edit set to vi
Press Esc and you can browse all commands with j and k keys.
it is like you moving cursor one line up and down in vi.
# 6  
Old 07-15-2005
Error easy way !

the easiest way is type an ! followed by the letter(s) of the command you want to use

say you have typed the following in your command prompt

ls -la
rm -rf /home/user1
du -k /home
find . -name "abc.out" -print

if you want to repeat the du
type
!d
if you want to do the ls
type
!l

Its an easy fast way to do just do the last thing you did again

I am not sure for how many commands it will work probably it gets it from
your history.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Clipboard retrieve/paste command

I mainly use Max/MSP for my audio programming, but today I am working on a project that requires the use of shell. Is it possible to do this? Retrieve the contents of the clipboard. Send a keystroke to an application without loosing focus, for example, I want to initiate a paste command (with... (0 Replies)
Discussion started by: fhill2
0 Replies

2. AIX

"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says D02:-/home/user1/temp> /job ksh: /job: not found. D02:-/home/user1/temp> previously it used to fetch all the commands which had job in it.. for example subjob, endjob, joblist etc... may I... (7 Replies)
Discussion started by: meetzap
7 Replies

3. Shell Programming and Scripting

How to retrieve data using awk command

I have a txt file with below data (textfile1.txt) select col1, col2 from Schema_Name.Table_Name1 select * from Schema_Name.Table_Name2 select col1, col2, col3 from Schema_Name.Table_Name3 select col1 from Schema_Name.Table_Name4 My output should look like Table_Name1 Table_Name2... (5 Replies)
Discussion started by: prasad4004
5 Replies

4. Shell Programming and Scripting

How to retrieve command line args one by on.

Hi, I have to store all the command line arguments into an array. I have the following code. ********************** #! /bin/sh set -A arr_no_updates i=1 while do arr_no_updates=$($i) echo ${arr_no_updates} i=$(($i+1)) done**************** (1 Reply)
Discussion started by: little_wonder
1 Replies

5. Shell Programming and Scripting

grep command to retrieve one file

The Sed/Grep command is really confusing me. I know I'm missing something that should be really easy to fix. My program displays multiple names after I ask it to display only one, How do I get it to do only one?? it looks like this: Please enter a name to display? >> John (A list then... (9 Replies)
Discussion started by: toejam
9 Replies

6. HP-UX

View command was typed

Hello All, I Am A New Member To This Group. Could you show me how to view all command was typed the same Redhat. Every I type arrow up and down to show the command was type but nothing to see. I must type it again. it is very slow. Thanks hoavn (4 Replies)
Discussion started by: hoavn
4 Replies

7. Solaris

command to retrieve user information

Hi, I want the command to retrieve the existing user information such as * authorization * Profile * role * exipre(expiration date of login) * inactive please tell me how to do that Thank you. (3 Replies)
Discussion started by: S_venkatesh
3 Replies

8. Shell Programming and Scripting

how to retrieve only the Use% value from df command

when I do a df -k for a particular mount i get the result like this Filesystem 1K-blocks Used Available Use% Mounted on /dev/ 4128448 3527496 391240 91% / I need to extract the value 91 from this and use it in my script in an if condition. How will i do it Please advice. (8 Replies)
Discussion started by: codeman007
8 Replies

9. Shell Programming and Scripting

How to save all the command typed -urgent

hi I want to know how to save all the command used by all the used under a particular root with the time stamp in a file. Eg: User Name: UX10 Time: 10:56 Command: LS User Name: UX23 Time: 10:59 Command: MORE abc.txt Please do help. thanks and regards -Anand (1 Reply)
Discussion started by: anandtharani
1 Replies

10. UNIX for Advanced & Expert Users

i am not able to recall the command typed earlier in unix

i am not able to recall the command typed earlier in unix whenever i press esc key ^[ comes on the unix prompt . so esc k isnt working for me whenever i press backspace key i get ^H on my unix cursor need help (1 Reply)
Discussion started by: murli1200
1 Replies
Login or Register to Ask a Question