Friday, May 17, 2024
15
rated 0 times [  15] [ 0]  / answers: 1 / hits: 2607  / 1 Year ago, tue, march 14, 2023, 4:28:28

How can I grab a command from history by number to my command line without executing it?


This immediately executes command number 555 which I'm not looking for:
$ history 10
$ !555

This opens the command up in an editor, which is overkill most of the time:
$ history 10
$ fc 555

This is an example of what I'm looking for:
$ history 10
$ #555
$ [command 555 from history listing now sitting here on my command line ready to edit or execute]

Thank you!


More From » command-line

 Answers
7
shopt -s histverify


If the histverify shell option is enabled, and Readline is being used, history substitutions are not immediately passed to the shell parser. Instead, the expanded line is reloaded into the Readline editing buffer for further modification.



[#1773] Wednesday, March 15, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
strhen

Total Points: 27
Total Questions: 111
Total Answers: 103

Location: Angola
Member since Tue, Apr 25, 2023
1 Year ago
;