The idea of adding a shell script from 1 to 100

First, use double brackets (()) to calculate#!/bin/bash#a=0for ((b=0; b; b++)); Do ((a=a+b)) // can also be written as a=$ ((a+b)) Done Echo $aSecond, seq, tr, sed, BC together to complete the calculation

"Column directory" of Shell programming learning

for a list of the current path under the directory (not the list of directories) method, and share with you ~ ~1. Using ls-d with wildcard charactersls-d * * 2, ls-f with grep query with/end of the content-F: Displays the directory behind the/ls-f |

The shell checks the network for abnormal, zombie process, memory is too low, automatic restart

#!/bin/bash while:do neterror=$ (/bin/netstat-a | GREP-CW "close_wait") echo "Get TCP netstate ' LISTEN ' num ber cuccessful! " echo "Neterror" $neterror if [$neterror-gt "]; then echo" too much net Error,system would reboot

Shell scripts build multiple libraries, multiple tables, multiple instances

cat createdbtable.sh#!/bin/bash#--------------------------------------------------   #Created : 2015-05-26#author:jimmygong#mail:[email protected] #Function: #Version: 1.0#------------------------------- -------------------mysqluser= "MySQL"

[Leetcode] [Shell] Tenth line

Tenth lineHow would you print just the 10th line of a file?For example, assume. has the file.txt following content:Line 1Line 2Line 3Line 4Line 5Line 6Line 7Line 8Line 9Line 10Your script should output the tenth line, which is:Line 10[Show hint]Hint:

Linux Shell Script Raiders (1.4)

1.4adding environment variables using functions1.4.1Introductionenvironment variables are typically used to store path lists, which are used to search for executables, library files, and so on. For example:$PATH,$ld_library_path, and they usually

Shell script with the IF small example

Use Whil for if to print a prime number less than 100#!/bin/bash#author Alvin#version 1.0.0#test for 1-100 Zhishua=2While [$a-le 100];DoZ=1for ((j = 2; $j If [$ ($a% $j))-eq 0];thenZ=0BreakFiDoneIf [$z-eq 1];thenEcho-ne $a "\ T"FiLet A+=1Done2 3 5 7

If process control in the shell

If flow control:Conditional judgment statements in the shell are similar to other programming languages.If you need to know what the criteria are, you can get help with man testCommon formatsFormat Oneif condition; ThenStatementFiFormat Twoif

For process Control in the shell

For loop:Used in the shell for looping. Similar to for in other programming languages, but somewhat different. The For loop is the most common syntax structure in bash.Common format Format OneFor variableDoStatementDoneFormat TwoFor variable in

While and unil process control in the shell

While loop:Format OneWhile condition;DoStatementDoneFormat Two dead loopsWhile TrueDoStatementDoneFormat three dead LoopsWhile:DoStatementDoneFormat Four dead LoopsWhile [1]DoStatementDoneFormat Five Dead LoopsWhile [0]DoStatementDone****************

Shell DHCP installation exercise

#!/bin/bash## 1, check whether the current user's identity has permissions# 2, check if there is a Yum source, if there is no need to create a Yum source configuration file# 3, install DHCP, if already installed, we can first remove and then install,

Related shell scripts for megacli

Tag: megacli shell awk raid 1. cat megacli.sh #!/bin/bash#--------------------------------------------------   #Created : 2015-05-22#author:jimmygong#mail:[email protected] #Function: #Version: 1.0#------------------------------- -------------------

Shell $ variable

$0: The current script has a file name of $num:num 1-based number,$ $ is the first argument, and $ is the second argument, and ${is thetenth argument $#: The number of arguments passed in the script $* : All positional parameters (as a single string)

2015.4.8 Shell Basics

1. Shell FeaturesOrder history!! !$!n! characterTab key to complete file path or commandAlias a= "B" Unalias AWildcard * Matches 0 or more characters? Match one characterInput/Output redirection >,>>,,2>>Pipe characterJob Control CTRL + Z jobs FG BG2

Shell Script parsing Nginx Log

This script parses the log of the Nginx load balancer:#!/bin/bashif [ $# -eq 0 ]; then    echo  "Error:please  specify logfile. " EXIT0ELSELOG=$1FIIF[!-F$1] ; then    echo  "Sorry,sir. i cat ' T find this apache  log file, pls try again! "     exit 0

A binary conversion in the shell

The default value in the shell is decimal, so how are binary, octal, and hexadecimal represented?Method 1: Use the prefix.0 begins with octal, and 0x starts with hexadecimal.As follows:#-----------------------------/chapter4/ex4-35.sh----------------

Display colored words in a shell script (Linux)

One, echo command (with parameter-e) cat color.sh#!/bin/bashecho -e  "\033[30m black \033[0m" echo -e   "\033[31m red \033[0m" echo -e  "\033[32m green \033[0m" echo -e  "\ 033[33m yellow \033[0m "echo -e " \033[34m blue \033[0m "echo -e " \033[ 35m 

Linux shell (dot space file name)

Today, when we look at the/etc/init.d/nginx script, we find that there is a lot of behavior in the script (the space name of the dot). For example, a few lines of file start:if [-r/etc/default/nginx]; Then

Sorting algorithm Big Collection _ Insert Class--Hill (shell) sort

The feature of this series of blogs is--give the results of each orderOriginally wanted to write a good process, get a picture of what, but think online analysis too much, are better, so these blog even if it is a summary of their own it.#include

Several methods of shell script execution, shell script

Several methods of shell script execution, shell scriptYou can execute shell scripts in the following ways: 1. The relative path method must be cd to the script path first. [Root @ banking tmp] # cd/tmp [root @ banking tmp] #./ceshi. sh script

Total Pages: 541 1 .... 486 487 488 489 490 .... 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.