It is often useful to reference the last argument to the most recently executed command in Bash. For instance, if one were to copy a file to a given directory, and then want to copy another file to the same directory, one might not want to type the entire path to the directory again. Fortunately, with the
!$ operator, this is unnecessary.linux@devbox:~/tip3> cp test1.png /root/Desktop/images/tip3
linux@devbox:~/tip3> cp test2.png !$
linux@devbox:~/tip3> cp test2.png !$
In the example above, instead of having to retype
/root/Desktop/images/tip3 when performing the second copy, the !$ operator was used instead, which is replaced with the last argument of the last command executed.
No comments:
Post a Comment