Previously run command.


 
Thread Tools Search this Thread
Operating Systems Linux Previously run command.
# 1  
Old 04-18-2009
Previously run command.

Hi,
In HP-UNIX I used to use ! before the command and type a portion of the comnand then if that command was previously run the whole line used to appear.

Eg : wc -l samplefile.txt

Next if I type !wc And Tab the previously run command would appear on the command prompt.

How to achive this in LINUX?

Thanks and Regards,
Gideon.
# 2  
Old 04-18-2009
I resort to !$ to repeat the immediately previous command or else run:
$ history | grep wc
get the line number and then type:
$ !<linenumber>

This is for bash, perhaps a bash shell guru will come up with a better answer?
# 3  
Old 04-20-2009
MySQL

Oh well that was nice.Smilie

I found another way, just want to share it here.

Type Ctrl + R. That will take us to the searh mode and the word typed would get the matching string in the latest command.

Again as you mentioned any one liners for the intial questions would be great!

Thanks for your reply sir!!!

Thanks and regards,
Gideon.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Unable to mount previously-working NFS share from NIM to LPAR

Right, now that I've finally worked out this website, I'll ask my question! I am having an absolute nightmare with NFS on AIX. I have used it many times, and I know what I'm doing, however I cannot fathom what is going on here. I have 2 LPARs, sitting on the same physical host. They are... (12 Replies)
Discussion started by: tmooredba
12 Replies

2. Shell Programming and Scripting

Bash question: working with an array of previously set variable strings

while i've used arrays to work with variables, i've never used them to loop through a set of strings and wanted to ask the community for some feedback or assistance. let me be specific. here's my code: # URL port Variables port2195=`nc -z $url2195 2195` port2196=`nc -z $url2196 2196`... (5 Replies)
Discussion started by: hungryd
5 Replies

3. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

4. Shell Programming and Scripting

Change the permission to previously used in unix ( chmod )

I have changed the premission of a file to 777. Now I would like to change permission to previously used ( UNDO ). Is there any command ?:confused: (3 Replies)
Discussion started by: frintocf
3 Replies

5. AIX

External Snapshot using previously defined lv

I prefer to assign my own lv names rather than the automatic LV creation that the snapshot Can it be done or is IBM's man page flawed? I am on AIX 6.1 TL 04 Machine type 9133-55A All local SCSI storage. I manually create the lv and attempt to create the snapshot: # mklv -y snapfs99... (2 Replies)
Discussion started by: Skyybugg
2 Replies

6. UNIX for Dummies Questions & Answers

go to previously visited directory

Is there a way to go back to the previously visited directory? say im in /dir1 then went to /dir2 and wanted to go back to /dir1. besides from aliasing every directory i have, i was wondering if there's a way to maybe alias a command to go to the previously visited directory just to make it more... (8 Replies)
Discussion started by: swag:þ
8 Replies

7. UNIX for Dummies Questions & Answers

How to find the details of the previously running process with PID

OS: Unix or Linux I (only) know the pid of the process which was running earlier (say 5 hrs back) but it is not running now. Is there a way I could find the details of that process? (atleast the name of the process). Please let me know. (2 Replies)
Discussion started by: vijay.d
2 Replies

8. UNIX for Advanced & Expert Users

how to erase files from a tape used previously on Windows operating system

hi all Please may you help. I want to put my unix application backup files using tar cv8 * from a specific folder e.g /u1/sage With new tapes SONY 4mm-DL 90m i can do it with no problem at all. Now I have run out of tapes and I need to use the same kind but they were once used to back... (5 Replies)
Discussion started by: isaac
5 Replies
Login or Register to Ask a Question