Use the command line-general Linux technology-Linux technology and application information quickly. The following is a detailed description. Historical Features
Use the history command to call up the list of commands used in history
Shell> history
...
994 cat config. nice
995 cd/usr/local/src
996 ls
997 cd/usr/src
998 ls
999 dmesg
1000 history
1001 history 100
If you want to re-Execute "cd/usr/local/src", you can call up the history as follows:
Shell>! 995
For simple and easy commands, it may be useless,
Cd/usr/local/src/ZendOptimizer-3.0.0-linux-glibc21-i386
./Configure? Prefix =/usr/local/gd? Without-x? Without-freetype? Without-fontconfig? Without-png
Such a long command may be helpful,
Obtain a parameter in the previous command.
For example, you have performed the following operations:
Shell> ls/bin/sh
Shell> file/bin/sh
In comparison, the parameters of the two commands are the same. In this case, you can use "!" To obtain the parameters of the previous command:
Shell> ls/bin/sh
Shell> file! : $
"!" The shell will be prompted to obtain a part of the above command as the current input, for example, $ indicates the end, that is, to obtain the last parameter of the ls command (in fact, this is also the first parameter.
Let's look at a long one.
Shell> tar zxvf httpd-2.0.59.tar.bz2
This is obviously an incorrect input. We all know that bz2 uses bzip for decompression. The corresponding tar parameter should use "jxvf". Then we can fix it as follows:
Shell> tar jxvf! : 2
"! : 2 "will get the 2nd parameters of the tar command above, as the historical input of the current input. The obtained parameters can not only be used independently, but also be used as part of the command as follows:
Shell> tar zxvf httpd-2.0.59.tar.bz2
Shell> tar jxvf! : 2-C/usr/tmo
After the above acquisition is executed, the command is replaced with tar jxvf httpd-2.0.59.tar.bz2-C/usr/tmo
The package will be decompressed to/usr/tmo according to the path specified by-C.
Command Execution result:
Tar:/usr/tmo: Cannot chdir: No such file or directory
Tar: Error is not recoverable: exiting now
Sorry, I accidentally typed it wrong. I was trying to extract it to/usr/tmp. At this time, another more interesting command came in handy,
"^" (Replace)
Shell> ^ mo ^ mp
This will replace the mo in the previous command line with mp
It's amazing. Your fingers are faster, but it's just a waste of time. I tapped 6 characters to handle the above error.
Some useful historical commands
! It is the default replacement symbol for bash and cshell.
!! Repeat the last command
! : S/xy/yx: replace xy in the last command with yx.
For example, etho xy! : S/xy:/yx
! So repeat the recent command starting with so.
!? Fn? Repeat the recently called fn command, which can be used in a parameter or a command name.
! 32. Run the command with the serial number 32.
!! & Will be added at the end of the last command & (any content can be added)
! : 0: select the command name instead of the entire line.
! : 3 Parameter
! : 2-4 2nd to 4 parameters
! :-3 from 0th to the third parameter
! ^ First Parameter
! $ Last parameter
! * First to last parameter
! : 2 * 2nd to the last
! : 2-starting from 2nd, but not ending Parameters
!? Fn? % Indicates the first time (sort fn1 fn2 fn3... => Echo !? Fn? % => Echo fn1)
Command Line Programming shell directly supports command line programming. For example:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service