BASH shell insert the arguments to a previous command into the current input line
Q. I’m using CentOS Linux server. How do I insert the arguments to a previous command into the current input line or fix errors in previous commands quickly?
A. BASH History expansion is useful and time saving feature. To designates the last argument of the preceding command use !$
For example, consider following command:
$ cp /tmp/file.name /path/to/somewhere/directory/file.name
$ cp !$ /home/you
!$ will automatically expand into /path/to/somewhere/directory/file.name, thus calling last command argument. See HISTORY expansion section by typing man bash command for more information:
man bash
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Pass command line argument to bash alias command
- Understanding Bash fork() bomb ~ :(){ :|:& };:
- Linux / UNIX : Argument list too long error in shell and solution
- How To Find and Overcome Shell Command Line Length Limitations
- Restrict Linux users to their home directories only
Tags: bash_shell, command_argument, history_expansion, Linux, linux_server, shell_tips, UNIX




Recent Comments
Today ~ 5 Comments
Today ~ 1 Comment
Yesterday ~ 1 Comment
Yesterday ~ 2 Comments
Yesterday ~ 10 Comments