I regularly find myself having to execute a lengthy command on a file, then process the results with other commands. To process the next file, I usually rerun the same command by hitting the Up key until I find the command I want and arduously replace the old filename with the new filename.
Is there a way to combine caret substitution (^oldfile^newfile
) with the n th-last command? I have (unsuccessfully) tried to pipe the n th-last command into the substitution like so:
$ !-4 | ^old^new
Of course, I am open to other suggestions. These little shortcuts really help with productivity...
:s
modifier!). Thanks a bunch. – Zaid Aug 22 '10 at 20:28!!
itself is merely a shorthand for!-1
. – isomorphismes Jan 03 '13 at 19:01