Instance 1: Step 1: Use VI to create a file **. Sh (this is not introduced here) #! /Bin/bash Note: This specifies the shell to explain the following command. CD/var/log # Switch the directory to/var/log (# It is the annotator in
Each line read by shell from a standard input or script is called a pipeline; it contains one or more commands ), these commands are separated by one or more pipe characters (|.
In fact, there are many special symbols that can be used to
1,! $ Is a special environment variable, which represents the last string of the previous command. For example, you may:
You can change it:
$ Mkdir mydir
$ MV! $ Yourdir#$ MV mydir yourdir
$ CD! $
2. ^ old ^ new
Replace some strings in
What is data stream redirection?
What is data stream redirection? This should be explained by the running result of the command! Generally, if you want to run a command, it will usually be like this:
Figure 5.1.1 data transmission
1.Use the value assignment statement:Format:LetValue assignment expression【Tip] The Value assignment expression can be omitted as follows:((Value assignment expression))Example: Give the independent variableIAdd1Let I = I + 1Or(I = I + 1) -----------
> Array
Names = (max Helen Sam Zach)
Names [*] extracts all data and returns it as an element.
Names [@] Retrieves all data, but returns an array, which can be used to assign values to the array.
> Export
Make the variables of the parent
You can execute multiple commands at a time in the command line, including the following: 1. Use between each command;SeparateNote: The execution of each command does not affect the execution of other commands. In other words, each command is
I don't have a tutorial. Let's talk about it!We get a shell. If we want to know more about it, we can't trace it in depth. There is no shortcut! You have to pay a lot of time and thinking and analysis. If you cannot do this, please give up. It is
[email protected]:~$ cat b.sh#!/bin/bashdir=`pwd`dir=$dir‘/‘for f in `ls *.png`do echo $dir$fdone
Check the execution of each line of code:
[email protected]:~$ bash -x b.sh++ pwd+ dir=/home/wade+ dir=/home/wade/++ ls chrome_1407299385726.png
ShellList the 10 most frequently used shellsHistory | 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] & quot; i} '| sort-Rn | HEADGrep-V "#". bash_history | awk '{++
Job Management
For example, after logging on to bash, we want to copy files, search data, compile data, and write vi programs! Of course, we can log on to the terminal environment of the six text interfaces again. However, can we achieve this in a
Read a file, assign each row to an array variable, and print it out in a for loop.
Copy codeThe Code is as follows :#! /Bin/sh
I = 1
SUM = 'sed-n' $ = 'tmp.txt '# calculates the total number of lines in the file.
Echo "$ SUM"
While read line
1. backup_run.sh
Copy codeThe Code is as follows :#! /Bin/sh
# Backup_run
# Script to run the backups
# Loads in a setting file for the user to change
SOURCE =/home/bob/backup. defaults
Check_source ()
{
# Check_source
# Can we load the file
#
This small program is simple, but it is the first shell script written by the novice. It has many factors to consider, but some errors are not handled ,,
#! /Bin/bash# Auth: dhh
Clear
Addr =/etc/yum. repos. d
Mkdir $ addr/bf>/dev/null 2> & 1
Mv $
When writing a program, printing out the progress or log information properly often helps us track the running results of the program. However, printing these results or logs on the screen does not serve as a basis for future checks. This is the
Preparation: 1. Prepare the rpm file to be installed.2. Write the rpm file to the file list pkg. lst (the file name is optional)3. install. shDirectory structure|-Install. sh|-Pkg. lst|-Readme.txt|-Xxxx. rpm|-Yyyy. rpm|-Installation process: 1. Put
Many people use third-party software to build FTP and WEB servers, which means IIS is complicated and difficult to use. it may be said that IIS is not secure. This is because you do not pay attention to your security policy settings, and then others
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