getopts is a built-in command of the shell.
getopts optstring name [args]
OPTIND,OPTARG,OPTERR
getopts is used by the shell program to analyze positional parameters. optstring contains
getopts is a built-in command of the shell.
getopts optstring name [args]
OPTIND,OPTARG,OPTERR
getopts is used by the shell program to analyze positional parameters. optstring contains
The shell script prints the nine-nine-nine multiplication table #!/bin/bash
for i in {1..9}
do
for j in {1..9}
do
if [$j -le $i]
then
echo -n “${j}X${i}= $(($i*$j)) ”
fi
done
Flow controlLogic processing in programming: Sequential execution
Select execution
Circular execution Loop Loop execution
Repeat a certain code segment several times
How many times it repeats
T
Advanced script oneOne, the second way of writing for loop:
As we all know, there are two ways of writing for
< strong>How to write directly:
Two parentheses must be written after
When the Shell script runs, it will first look for the system environment variable ENV, which specifies the environment file (the order of loading is usually /etc/profile, ~/.bash_profile, ~/.bashr
1. Count the number of digits in the document
2. Compare the differences between the files of the two machines
#!/bin/bash
dir=/data/web
[ -f /tmp/md5.list] && >/tmp/md5.lis
1. while loop
Syntax structure: while condition; do……; done
1) Infinite loop
While:
do
command
done
2) Endless loop
While 1
Do
command
Blog post outline:
Don’t talk nonsense, just use the grammar example:
Requirement①:
first name and 2. last name, and finally displayed on the screen: “Your full name is:” content:
Question requirements
Write a shell and see if there are custom users (ordinary users) in your Linux system. If so, how many?
Core points
centos6 uid>=500
eentos7 uid>=1000
awk -F’:”
shell
See 100 linux shell questions.
Function to reduce duplication of code.
Shell is a collection of system commands
The first line starts with #!/bin/bash
#!/bin/bash
echo “123”
w
ls
Sp