Hack 62. Substitute a specific argument for a specific command
by Ramesh
In the example below, !cp:2 searches for the previous command in history that starts with cp and takes the second argument of cp and substitutes it for the ls -l command as shown below.
- # cp ~/longname.txt /really/a/very/long/path/long-filename.txt
- # ls -l !cp:2
- ls -l /really/a/very/long/path/long-filename.txt
In the example below, !cp:$ searches for the previous command in history that starts with cp and takes the last argument (in this case, which is also the second argument as shown above) of cp and substitutes it for the ls -l command as shown below.
- # ls -l !cp:$
- ls -l /really/a/very/long/path/long-filename.txt
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .