Having found an old (long) command from history I want to copy, modify and execute it. Is there a shortcut key to copy that long string? I do not use mouse.
Press Ctrl + R and start typing a text from a command that you want to get from the history. The latest command with the text that you typed in will appear. Press Ctrl + R again to move to the next command, which contains entered text, until you get the command you are searching for. Then you can move within command with right and left keys and change it as you like. When you are done, just press Enter. You don't need to copy the command as you can recall it anytime.
Well yes there is. Just enter an exclamation mark (!) followed by the command serial number which you can get it from history. For detailed example Open up a terminal and type command
You will definitely see a list of commands you entered with serial number in the left side against each command say as follows.
well if you want to execute sudo apt-cache search Inkscape the slno concerned with that command in the above pic is 311 so in the terminal just enter
Well if you want to edit the before executing the command while using above method , you need to set histverify ON so that it will alsways ask for verification before executing. So for that just execute the command once for hassle free use of above method as follows :
shopt -s histverify
Thats it ,