Any way to recall the file of previous cmd? [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
What does !$ mean?
3 answers
Shell: How do I get the last argument the previous command when it was detached?
4 answers
Frequently IâÂÂll have to do some digging around to figure out what IâÂÂm doing on linux, involving quite a bit of âÂÂâÂÂ, âÂÂls -laâÂÂ, âÂÂcdâÂÂ, âÂÂcatâÂÂ, and âÂÂvimâÂÂ
Is there any way to quickly reuse the file/target of the previous command?
e.g. I have to look around for a file, say with ls, and when IâÂÂve found it IâÂÂll need to use it with a program like cat or vim. So letâÂÂs say IâÂÂve got âÂÂls -la /some/path/SomeNameâ and hit , say IâÂÂve drilled down to where this is the file I was looking for. What IâÂÂd like to do is some kind of âÂÂ!!â Like when you forget to use sudo; Say I really want to use âÂÂcatâ but had been searching around with âÂÂlsâ and âÂÂâ - or IâÂÂve been searching around with âÂÂcatâÂÂ, up-arrow and continuing to refine my âÂÂcat /file/path/â and then when IâÂÂve found what IâÂÂm looking for IâÂÂll want to edit that file
IâÂÂd like to be able to do something like âÂÂcat !!â or âÂÂvim !!âÂÂ
linux bash shell command-line alias
marked as duplicate by muru, Stephen Rauch, G-Man, SatÃ
 Katsura, ñÃÂsýù÷ Oct 2 '17 at 3:27
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
What does !$ mean?
3 answers
Shell: How do I get the last argument the previous command when it was detached?
4 answers
Frequently IâÂÂll have to do some digging around to figure out what IâÂÂm doing on linux, involving quite a bit of âÂÂâÂÂ, âÂÂls -laâÂÂ, âÂÂcdâÂÂ, âÂÂcatâÂÂ, and âÂÂvimâÂÂ
Is there any way to quickly reuse the file/target of the previous command?
e.g. I have to look around for a file, say with ls, and when IâÂÂve found it IâÂÂll need to use it with a program like cat or vim. So letâÂÂs say IâÂÂve got âÂÂls -la /some/path/SomeNameâ and hit , say IâÂÂve drilled down to where this is the file I was looking for. What IâÂÂd like to do is some kind of âÂÂ!!â Like when you forget to use sudo; Say I really want to use âÂÂcatâ but had been searching around with âÂÂlsâ and âÂÂâ - or IâÂÂve been searching around with âÂÂcatâÂÂ, up-arrow and continuing to refine my âÂÂcat /file/path/â and then when IâÂÂve found what IâÂÂm looking for IâÂÂll want to edit that file
IâÂÂd like to be able to do something like âÂÂcat !!â or âÂÂvim !!âÂÂ
linux bash shell command-line alias
marked as duplicate by muru, Stephen Rauch, G-Man, SatÃ
 Katsura, ñÃÂsýù÷ Oct 2 '17 at 3:27
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Also see: askubuntu.com/q/304830/158442
â muru
Oct 2 '17 at 0:25
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
What does !$ mean?
3 answers
Shell: How do I get the last argument the previous command when it was detached?
4 answers
Frequently IâÂÂll have to do some digging around to figure out what IâÂÂm doing on linux, involving quite a bit of âÂÂâÂÂ, âÂÂls -laâÂÂ, âÂÂcdâÂÂ, âÂÂcatâÂÂ, and âÂÂvimâÂÂ
Is there any way to quickly reuse the file/target of the previous command?
e.g. I have to look around for a file, say with ls, and when IâÂÂve found it IâÂÂll need to use it with a program like cat or vim. So letâÂÂs say IâÂÂve got âÂÂls -la /some/path/SomeNameâ and hit , say IâÂÂve drilled down to where this is the file I was looking for. What IâÂÂd like to do is some kind of âÂÂ!!â Like when you forget to use sudo; Say I really want to use âÂÂcatâ but had been searching around with âÂÂlsâ and âÂÂâ - or IâÂÂve been searching around with âÂÂcatâÂÂ, up-arrow and continuing to refine my âÂÂcat /file/path/â and then when IâÂÂve found what IâÂÂm looking for IâÂÂll want to edit that file
IâÂÂd like to be able to do something like âÂÂcat !!â or âÂÂvim !!âÂÂ
linux bash shell command-line alias
This question already has an answer here:
What does !$ mean?
3 answers
Shell: How do I get the last argument the previous command when it was detached?
4 answers
Frequently IâÂÂll have to do some digging around to figure out what IâÂÂm doing on linux, involving quite a bit of âÂÂâÂÂ, âÂÂls -laâÂÂ, âÂÂcdâÂÂ, âÂÂcatâÂÂ, and âÂÂvimâÂÂ
Is there any way to quickly reuse the file/target of the previous command?
e.g. I have to look around for a file, say with ls, and when IâÂÂve found it IâÂÂll need to use it with a program like cat or vim. So letâÂÂs say IâÂÂve got âÂÂls -la /some/path/SomeNameâ and hit , say IâÂÂve drilled down to where this is the file I was looking for. What IâÂÂd like to do is some kind of âÂÂ!!â Like when you forget to use sudo; Say I really want to use âÂÂcatâ but had been searching around with âÂÂlsâ and âÂÂâ - or IâÂÂve been searching around with âÂÂcatâÂÂ, up-arrow and continuing to refine my âÂÂcat /file/path/â and then when IâÂÂve found what IâÂÂm looking for IâÂÂll want to edit that file
IâÂÂd like to be able to do something like âÂÂcat !!â or âÂÂvim !!âÂÂ
This question already has an answer here:
What does !$ mean?
3 answers
Shell: How do I get the last argument the previous command when it was detached?
4 answers
linux bash shell command-line alias
linux bash shell command-line alias
asked Oct 2 '17 at 0:14
EE1337
11
11
marked as duplicate by muru, Stephen Rauch, G-Man, SatÃ
 Katsura, ñÃÂsýù÷ Oct 2 '17 at 3:27
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by muru, Stephen Rauch, G-Man, SatÃ
 Katsura, ñÃÂsýù÷ Oct 2 '17 at 3:27
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Also see: askubuntu.com/q/304830/158442
â muru
Oct 2 '17 at 0:25
add a comment |Â
Also see: askubuntu.com/q/304830/158442
â muru
Oct 2 '17 at 0:25
Also see: askubuntu.com/q/304830/158442
â muru
Oct 2 '17 at 0:25
Also see: askubuntu.com/q/304830/158442
â muru
Oct 2 '17 at 0:25
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
If you are using bash with emacs key bindings then you need to know about ESC period (aka dot aka full stop). You can also use $_
add a comment |Â
up vote
0
down vote
It sounds like you're looking for the "history event" syntax for arguments. You mention !!
, which repeats the whole previous command. But, you can also refer to specific arguments from that command, or all of them. !^
will get you the first argument; !$
will get you the last one (think vi commands or regular expression syntax) and !*
will get you all of the arguments (but not the command itself).
So, after finding your file with ls -l /etc/passwd
, you could do cat !$
to display its contents.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you are using bash with emacs key bindings then you need to know about ESC period (aka dot aka full stop). You can also use $_
add a comment |Â
up vote
0
down vote
If you are using bash with emacs key bindings then you need to know about ESC period (aka dot aka full stop). You can also use $_
add a comment |Â
up vote
0
down vote
up vote
0
down vote
If you are using bash with emacs key bindings then you need to know about ESC period (aka dot aka full stop). You can also use $_
If you are using bash with emacs key bindings then you need to know about ESC period (aka dot aka full stop). You can also use $_
answered Oct 2 '17 at 0:24
icarus
4,7781725
4,7781725
add a comment |Â
add a comment |Â
up vote
0
down vote
It sounds like you're looking for the "history event" syntax for arguments. You mention !!
, which repeats the whole previous command. But, you can also refer to specific arguments from that command, or all of them. !^
will get you the first argument; !$
will get you the last one (think vi commands or regular expression syntax) and !*
will get you all of the arguments (but not the command itself).
So, after finding your file with ls -l /etc/passwd
, you could do cat !$
to display its contents.
add a comment |Â
up vote
0
down vote
It sounds like you're looking for the "history event" syntax for arguments. You mention !!
, which repeats the whole previous command. But, you can also refer to specific arguments from that command, or all of them. !^
will get you the first argument; !$
will get you the last one (think vi commands or regular expression syntax) and !*
will get you all of the arguments (but not the command itself).
So, after finding your file with ls -l /etc/passwd
, you could do cat !$
to display its contents.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
It sounds like you're looking for the "history event" syntax for arguments. You mention !!
, which repeats the whole previous command. But, you can also refer to specific arguments from that command, or all of them. !^
will get you the first argument; !$
will get you the last one (think vi commands or regular expression syntax) and !*
will get you all of the arguments (but not the command itself).
So, after finding your file with ls -l /etc/passwd
, you could do cat !$
to display its contents.
It sounds like you're looking for the "history event" syntax for arguments. You mention !!
, which repeats the whole previous command. But, you can also refer to specific arguments from that command, or all of them. !^
will get you the first argument; !$
will get you the last one (think vi commands or regular expression syntax) and !*
will get you all of the arguments (but not the command itself).
So, after finding your file with ls -l /etc/passwd
, you could do cat !$
to display its contents.
answered Oct 2 '17 at 0:40
mattdm
27.1k1170109
27.1k1170109
add a comment |Â
add a comment |Â
Also see: askubuntu.com/q/304830/158442
â muru
Oct 2 '17 at 0:25