LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Keyboard shortcut for last entered param in command line ? (https://www.linuxquestions.org/questions/linux-newbie-8/keyboard-shortcut-for-last-entered-param-in-command-line-4175438112/)

hongkildong 11-21-2012 07:14 AM

Keyboard shortcut for last entered param in command line ?
 
I watched a linux tut video and noticed some cool trick. Can you explain how he managed to insert string "/sbin/mkfs.ext2" at 0:30 ? He hadn't selected it before. Is it some sort of keyboard shortcut for last entered param ?
http://www.youtube.com/watch?v=ZIQCd1RvbGk

teckk 11-21-2012 08:45 AM

I don't speak that language. Maybe Ctrl+P for last entered.

shivaa 11-21-2012 09:47 AM

You can print last argument of previously run command using ALT + . (ALT key plus dot) keyboard combination.
Code:

bash$ ls -ld /home/jack/test
bash$ cd (ALT + .)

And it will print:
Code:

bash$ cd /home/jack/test
Note: CTRL+P will print previously run command, not last argument of previous cmd.

catkin 11-21-2012 10:01 AM

Ctrl+Alt+y would also do it. Reference here.

mandyapenguin 11-21-2012 10:10 AM

Simply you can use up arrow key to get last command.
And using exclamatory(!) symbol also you can excecute the commands of previous command(s).
For example I have ran 3 commands
Code:

vi /etc/samba/smb.conf  -->1st
ping -c5 google.com    -->2nd
tail -f /var/log/syslog -->3rd

Now if I again want to open /etc/samba/smb.conf file, just type & hit enter
Code:

!v
Using history numbers also you can run any previosly excecuted commands
Code:

#history
2023  cal
2024  man dig
2025  nslookup localhost
2026  echo $?
2027  whoami
2028  w
2029  who
2030  tree -d /etc
2031  vi /etc/samba/smb.conf
2032  ping -c5 google.com
2033  tail -f /var/log/syslog

If you want to run command of history number 2030 just type
Code:

!2030
Here are some Linux Keyboard Shortcuts

hongkildong 11-21-2012 11:20 AM

Thanks! You are so incredibly helpful )

catkin 11-22-2012 04:16 AM

Quote:

Originally Posted by hongkildong (Post 4834147)
Thanks! You are so incredibly helpful )

Yes -- about re-running complete commands. The OP was about pasting the last argument of the last command.


All times are GMT -5. The time now is 07:41 AM.