Conditional expression ("CONDITIONAL EXPRESSIONS")
Conditional expressions are used in [composite commands and built-in command test and [to test file properties for string and arithmetic comparisons.] An expression is constructed using the
System: CentOS 5.xOpenSSL upgrade script content:Cat openssl_update.sh
The code is as follows
Copy Code
#!/bin/bashif [[$EUID-ne 0]]; Thenecho "This script must is run as root" 1>&2Exit 1FiYum-y Install glibc* cpp gcc*
In order to more easily know the memory usage on the server, and according to the memory use size to restart the service, I only the whole fault alarm, if you want to automatically restart the service, we will have to modify their own.
Script
A start to build the Chinese blog Alliance, both bloggers remind me to do Web site Daquan maintenance of this kind of website is very troublesome, need a lot of energy to debug some of the aborted site, but also to take the blog Encyclopedia of Pine
The Linux shell can be user-defined, and can be invoked randomly in a shell script. Here's how it's defined, and what the call needs to pay attention to.
First, define the shell function (define functions)
Grammar:
[Function] funname [()]
Hadoop, distributed large data storage and computing, free open source! Linux based on the students to install a relatively smooth, write a few configuration files can be started, I rookie, so write a more detailed. For convenience, I use three
In the day-to-day operation of the flow of traffic will find the phenomenon of sudden increase or increase in server load and so on, in order to find out why, need to use the Nginx limit module to access IP restrictions, and then can analyze the log.
Linux shell sed awk command (2)-awkawk syntax Format:awk [Options]-F program-file [--] file ...Options:-F FS,--field-separator FSCreate a delimiter with FS as the input line (the default delimiter is a space or tab)-V Var=val,--assign var=valBefore
# # 1. Create a new shell script ##1. Create a text file that contains the bash command. The first line of the file should be:#!/bin/bash2. Make the file executable (using chmod +x scripts)3. script debug mode :#!/bin/bash-x# Bash-x Scripts# # 2.
/bin/bash,/bin/sh,/bin/csh ...The general Linux Default User shell is bash, which means you can log in and knock commands.Non-landing shell, the classic/bin/nologin is a non-landing shell, that is, if a user default shell is it, the user even log
The shell is a programming language and a service that accesses the operating system kernel.The types of shell that are common to Linux are:Bourne Shell (/usr/bin/sh or/bin/sh)Bourne Again Shell (/bin/bash)C Shell (/USR/BIN/CSH)K Shell (/usr/bin/ksh)
for commandfor Var in listDoCommandsDoneCode 2-1[Email protected]:/data# cat demo1 #!/bin/bashfor test in Alabama Alaska Arizona Arkansas ' California Colorado ' do Echo "The next state is $test" Doneecho "The last state we visited be $test"
1, reading parameters: Positional parameter variable is the standard number: $ $ is the program name, "$" is the first parameter, and the second argument is ... 1 #!/bin/bash 2 # using one command line parameter 3 4 factorial=1 5 for
Bash Shell built-in commands and reserved wordsCommandMeaning!Reserved words, logical non-:Don't do anything, just do the parameter expansion.Read the file and execute it in the shellAliasTo set a command or command-line aliasBgTo run a job in the
If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.As an example:
#!/bin/bash
A=ten
echo-
The printf command is used to format the output and is an enhanced version of the echo command. It is a finite variant of the C-language printf () library function, and is somewhat different in syntax.Note: printf is defined by the POSIX standard,
[ -a file] is true if file exists. [ -b file] True if file exists and is a block special file. [ -c file] True if file exists and is a word special. [ -d file] True if file exists and is a directory. [ -e file] is true if file exists. [ -f file]
1. Basic knowledge Preparation 1.1. Linux background processUNIX is a multitasking system that allows multiple users to run several programs at the same time. The Shell's metacharacters & provides a way to run programs in the background that do not
The shell is much more programmatic in terms of programming than Windows batch processing, both in loops and operations.Bash supports one-dimensional arrays (which do not support multidimensional arrays) and does not limit the size of arrays.
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.