5. The world's largest source code warehouse GitHub, the number of shell-related projects accounted for 8%, among the top 5 and Java equivalent, visible in the actual combat project, the shell is Paulto. Picture sources, see here
Some mighty commands.
Share some of the shell usages and scripts that you may not know, simple & powerful!
Before reading the following sections, it is strongly recommended that the reader open a shell experiment, which is not da Lu Huo in the shell textbook Oh:
1.!$<!$ is a special environment variable that represents the last string of the previous command. Such as: You may be like this:
$mkdir Mydir
$MV Mydir Yourdir
$CD Yourdir
Can be changed to:
$mkdir Mydir
$MV!$ Yourdir
$CD!$
2, sudo!! Executes the previous command as root.
Scenario Examples: For example, Ubuntu uses Apt-get to install software packages that require root identity, and we often forget to add sudo before apt-get. Each time you have to add sudo and retype this line of command, it is convenient to use sudo!! Done.
Chenhao: Cool shell blogger (@ Left ear mouse) Note: Under the shell, sometimes you will enter a very long command, you can use!XXX to repeat the last command, for example, you previously entered, vi/where/the/file/is, next time you can use!vi The last VI command was heavy. 】
3, cd– back to the previous directory.
Examples of scenarios: The current directory is/home/a, with CD. /b switch to/home/b. You can easily switch back and forth between/home/a and/home/b by repeatedly executing the cd– command.
(Chenhao Note: cd ~ is to go back to your home directory, CD ~user, is to enter a user's directory)
4. ' Alt +. ' or ' <ESC> ' Jechin ALT +. or esc+. You can repeat the arguments to the last command line.
5. ^old^new replaces a partial string in the previous command.
Scene: Echo "wanderful" is actually trying to output the echo "wonderful". It only takes a ^a^o to have a lot of help with the wrong spelling of a long command. (Chenhao Note: You can also use!!:gs/old/new)
6, Du-s * | Sort-n | Tail
Lists the largest 10 files in the current directory.
7.: w!sudo Tee%
Save a file in vi that only root can write
8, date-d@1234567890
Time Cut Time
9, > File.txt
Create an empty file that is shorter than the touch.
10, MTR coolshell.cn
MTR command is better than traceroute.
Add a space before the command line, and the command does not go into the history.
11, echo "Ls-l" | At midnight
Run a command at some time.
12, Curl-u user:pass-d status= "Tweeting from the shell" Http://twitter.com/statuses/update.xml
command line to update Twitter.
13, Curl-u username–silent "Https://mail.google.com/mail/feed/atom" | Perl-ne ' print ' \ t ' if/<name>/; Print "$2\n" if/< (Title|name) > (. *) <\/\1>/; '
Check your Gmail unread messages.
14, ps aux | Sort-nk +4 | Tail
Lists the first 10 most memory-consuming processes
15, man ASCII
Displays the ASCII code table.
Scenario: Do you still need Google when you forget your ASCII code table? Especially if the celestial network is so "smooth", it is even more troublesome to apply the rule more often in GWF, directly using the local man ASCII.
16, Ctrl-x E
Quickly start your default editor (set by the variable $editor).
17, NETSTAT–TLNP
Lists the port numbers on which the native process listens. (Chenhao Note: Netstat-anop can display the process listening on this port number)
18, Tail-f/path/to/file.log | Sed '/^finished:success$/q '
Exit tail when finished:success occurs in the File.log, which is used to monitor and filter the log for real time to see if a record appears.
19, SSH User@server Bash </path/to/local/script.sh
Run a script on the remote machine. The best thing about this command is that you don't have to copy the script to the remote machine.
20, ssh user@host cat/path/to/remotefile |http://files.jb51.net/files/uploadimg/20121123/1109370.png-gravity Northwest-background transparent-extent 720x200 Output.png
Change the size of the picture
21, Lsof–i
View the active state of the local network service in real time.
22, Vim Scp://username@host//path/to/somefile
Vim a remote file
23, Python-m Simplehttpserver
One word implementation of an HTTP service, the current directory as the HTTP service directory, can be accessed through http://localhost:8000 this is perhaps the planet's simplest HTTP server implementation.
24, History | awk ' {cmd[$2]++;count++;} End {to (a in CMD) print Cmd[a] "cmd[a]/count*100"% "A}" | Grep-v "./" | Column-c3-s ""-t | Sort-nr | NL | Head-n10
(Chenhao Note: A bit complicated, History|awk ' {print $} ' |awk ' BEGIN {fs= ' |} {print $} ' |sort|uniq-c|sort-rn|head-10)
This line of script can output the 10 commands you use most often, and you can even gain insight into what kind of programmer you are.
25, Tr-c "[:d igit:]" "" </dev/urandom | DD cbs= $COLUMNS Conv=unblock | Grep_color= "1;32″grep–color" [^] "
Want to see the Marix screen effect? (not very much alike, but also very cool!)
Don't know the code? It doesn't matter, system learn *nix shell script, recommend "Linux command line and Shell script programming encyclopedia".
Finally, the words of the shell: (Chenhao Note: The following the mug is very good ah, 404null.com very interesting).
"Where There is a shell,there is a way!"
Unix Shell Color Mug