Shell statistics Word Frequency script

  #!/bin/bashif [$#-ne 1];then echo "usage:$0 filename"; Exit-1fifilename=$1egrep-o "\b[[:alpha:]]+\b" $filename | awk ' {count[$0]++}end{printf ("%-14s%s\n", "Word", "Count"), for (Ind in count) {printf ("%-14s%d\n", Ind,count[ind]);}}

Operations Common Shell

List The 10 shells you use mostHistory | awk ' {a[$2]++}end{for (i in a) {print a[i] "i}} ' | Sort-rn | HeadHistory | awk ' {a[$4]++}end{for (i in a) {print a[$i] " " i}} ' | sort-rn | headgrep-v "#". Bash_history |awk ' {++a[$1]}end{for

Some application scenarios for the shell

List the number of connections per IPawk ' /^tcp/{print} ' awk ' !/^::/{print $ {} ' Sort Uniq Sort awk ' begin{printf "%-10s%s\n", "Connum", "IP"}{printf "%-10s%s\n", $1,$2} 'Command explanation: Netstat-n refused to display aliases, can

[Shell] Regular expressions and wildcard characters

-------------------------------------------------------------------------------------Regular expressions and wildcard characters:1. The regular expression is used to match the qualifying string in the file , and the Regex contains the match . grep,

Linux:shell Common wildcard characters

character meaning * Match 0 or more characters ? Match any one character [list] Match any single character in the list [!list] Matches a character other

September 13, 2015 Course assignments-Questions about the shell

1. Describe the operation principle of shell program (can be attached with necessary graphic instructions);   Span style= " font-size:12px;">shell is a special program that is officially defined as the interface to the kernel and is

Crontab call shell script does not run

A shell script was recently invoked with Crontab, and a Python script was invoked inside the shell scriptIn fact, it is to abandon Python to write a judgment trouble, using the shell to write a if to judge the case to run this Python script.But

Use shell script to build LNMP environment in one click

In order to match the previous text, here first to organize a key how to deploy LNMP environment;In fact, small and medium-sized enterprises in the production environment is also very like to use such software packages, because after all, the source

Linux Shell Programming (2): For while

for((i =0; I 5; i++)) Do Echo "Current number is $i" DoneSERVICES="8000-3306" forXinch$SERVICES Do Echo$x Done forXincha b c Do Echo$x Done forIinch$* #$* is a string:"parameter 1 parameter 2 ..."form to save all parameters Do

Shell (a) variable

First shell #!/Bin/bash echo "Hello world!" The "#!" fixed tag is used to specify which interpreter the script uses to parse the script and must have Execute permissions chmod+X./test.sh increased execution permissions./Test.sh executes the script

[Shell] Bash variables: Custom variables

/*-------------------------------------------------------------------------------------------@ Black eyed poet --------------------------------------------------------------------------------------------*/A variable is a unit of computer memory

Shell arithmetic operations

Reprinted from: Linux Shell arithmetic operationsThere are four ways in which the Bash Shell's arithmetic operations are:1: Using expr external programAddition R= ' Expr 4 + 5 'Echo $rAttention! ' 4 ' + ' 5 ' There should be a gap between the threeR=

Variable substitution in the shell

${STR-NEWSTR} is only replaced when STR is NULL${STR:-NEWSTR} replace when STR is null or if STR is an empty stringAll in all,-number, when STR has no content, then replace,: The number just increases the case of an empty string. Note that the

Leetcode's Shell Part 4 questions finishing

Some of the details of the shell are not very familiar with, borrowed a lot of other people's Things1. Word Frequency This problem is simple, as long as can be sorted can be cat words.txt |tr-s "" \ n "sort | unique-c | Sort-r | awk ' {print $ ' $ '

The Helloword of the shell

The Helloword of the shellCd/binLs-l | Find-name SHLs-l | FIND-NAMD BashLs-l | Grep-r sh sh is actually pointing to dashlrwxrwxrwx 1 root root 4 2014-12-11 03:13 sh, dashLs-l | Grep-r BashCD ~mkdir ShellVI hello.sh#!/bin/bash//fixed notation,

Shell Parameters Hollow Lattice

When using the shell to pass parameters.Do not use shift when parsing parametersAction= "$" case "$action" in status) shift [email protected] exit $?    ;; .. *) help exit-1;; EsacBecause even if there are double quotes, it cannot be passed

Shell-nginx Startup scripts

########################################################################## file name: nginx.sh#  Author: dty# mail: [email protected]# Created Time: Sun 09  aug 2015 06:02:17 pm cst################################################################## ##

Read in the shell

Assigning values using read-in variablesParameters-P Setting prompt information-T set timeout timeHow to use:[Email protected] script]# read-p "pls input:" n pls input:12 [[email protected] script]# echo $n 12Special usage[email protected] script]#

Used Linux Shell Command before

--run. SH Job commandSh. sh--let Job run behind stageNohup ./.sh&--met error as below when rub. SH jobError ' XX.sh:line XX:sqlplus:command not found 'Method:source. Bash_profile--delete file,-f (delete directly without remaind)rm-f filename--delete

Multi-thread Linux Shell script and linuxshell

Multi-thread Linux Shell script and linuxshell In bash, we run (&) in the background to implement multithreading. for((i=1;i We have added {} & so that the execution in {} can be performed in the background. The above is equivalent to executing

Total Pages: 541 1 .... 470 471 472 473 474 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.