#!/bin/bash #Write a script#1. Set the value of the variable file to/etc/passwd#2. Say hello to each user in/etc/passwd and say what the ID is.#shaped like:#Hello,root,your UID is 0. FILE=/etc/passwd COUNT= ' Wc-l${file}| Cut-f1-d" "` forIinch'
There are several commands on the Linux system for file search, such as: Locate,wheris and find are more commonly used in work.1.locate command: Locate the lookup file is based on the/var/lib/mlocate database, which contains all the local file
1. List of files and directories 1.1 more common Linux top-level virtual directory names and their contents:
Directory
Use
/
The root directory of the virtual directory. Files are not usually stored here
First, Shell script introduction
The shell is a program written in C that is a bridge for users to use Linux. The shell is both a command language and a programming language.
The shell is a scripting language;
Can use logic
In the shell script, the variable definition, the reference each has the different way, in addition, very commonly has the file attribute judgment, the logical operation, the numerical operation and so on, the following record their attribute
Recently around here for a long time ah, now reluctantly come out, share a little understanding of their ownExit statusA program once run must have only two kinds of results, either success or failure, the result of success is the same, the reason
1, write script/root/bin/systeminfo.sh, display the current host system information, including hostname, IPV4 address, operating system version, kernel version, CPU model, memory size, hard disk size#!/bin/bashecho "hostname: `hostname`"echo "ipv4
Chapter 1th whileLooping Statementsin a programming language , a while loop is a statement of a control flow that uses an expression that returns a Boolean value that, when the return value of the expression is true , repeats the condition of the
What is direct assignment?1. The way the author directly assigns parameter values is called direct assignment.2. In general, an indirect assignment is assigned by an interactive method.Example 1:varl=arppinging.comThis is a direct assignment that is
Shellscript Common script:ForLoopsWheil Many loops can be replaced with a for loopFor loop syntax structureFor variable name in variable Value listDoinstructionDoneFor ((EXP1;EXP2;EXP3))DoinstructionDoneScript instance:For 99multiplication
Logical operations in shell programming, with or without, short-circuit operations, XOR operations, we use the simplest way to understand the XOR.XOR: ^XOR two values, same as false, different for trueUnderstandably, two values refer to binary
Shell Scripting Learning RecordWhy learn shell scripts?In some complex Linux maintenance work process, a large number of repetitive input and interactive operation is not only time-consuming and difficult, and error-prone, however, writing shell
Write a simple alarm system with the shell
Create a directory structure
mkdir -p /usr/local/sbin/mon/{bin,conf,shares,mail,log}mon //主目录bin //主程序目录shares //子程序目录mail //发邮件目录log //日志目录Program Main entry
Before using shell to write scripts, sometimes not only to define a configuration file, often have a template, different environments directly replace the same template content to use, however, until then, has been used in the SED, awk, grep and so
1.1 The following table is a logical operatorTips:! Inverse: A logical value that is opposite to a logical value.-A Chinese meaning is with (&&): Two logical values are true return values are true, and vice versa is false.-O Chinese meaning yes or
1.bash supports one-dimensional arrays (multidimensional arrays are not supported) and does not qualify the size of the array(1) define an array:Array_name= (value0 value1 value2 value3)OrArray_name= (Value0Value1value2Value3)or individually defined:
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.