Because the shell does not support direct multiline annotations, it summarizes the following workarounds for multiple lines of shell annotations one, through here documents and: Realize 1, the simplest method: a=b:~> Cat This are \ $A: $A > End
Sometimes run a shell script error, generally can not find the shell file, mostly because the script is generated under Windows and then copy to Linux, with the following command check:
$ head-1 Yourscript | Od-c
And the IT ends:this is wrong
000000
This article, as the last article in the Shell script Base series, does an exercise here. How to use a For loop to execute a command.
1. Use for loop to execute different commands
2.for loop Plus if statement print file
Put the script file
IFS:
The use of IFS directly to explain what the specific ifs is doing ... Own Google
First create a file of "a", and "a":
Then we look at the LS:
--> ls
a A a That is true.
And then if we need to write a script to manipulate each file:
--> for
The shell is used to solve the problem of how users communicate with the operating system. In fact, we all have a misunderstanding of the concept of shell, as if the command line shell is called shell. The shell, in fact, is the shell. As
After logging into the system, we are the Shell interaction environment, use it every day to work, have a customized environment can make us more efficient.1.PS1 variableIt is found that there is a string of characters on the left side of the cursor
See if the script syntax has errors:Bash-n modify_suffix.shTrack executionSh-x modify_suffix.sh AAA1.${var} 2.$ (cmd) 3. () and {} 4.${var:-string},${var:+string},${var:=string},${var:?string} 5.$ ((exp)) 6.$ (Var%pattern), $ (var%%pattern), $
The find command is used for searching. It has powerful functions in the following format:
Find pathname-options [-print-Exec-OK...]
Pathname: directory path searched by the find command. For example, use "." To represent the current
Step 1: Master several if statement branches
The following is the most complete if format. You can delete it as needed in actual use.
If condition; then
// Action
Elif conditon: then
// Action
... Several intermediate Elif
Else
//
1 For Loops
Structure:
For ARG in [LIST]
Do
Command (s )...
Done
#! /Bin/bashsum = 0for int in 1 2 3 4 5do sum = 'expr $ sum + $ int 'doneecho $ sum
2 while
Determine whether the condition is met at the beginning of the
1. CTRL + W Delete the last word
2. CTRL + u delete a row
3. CD-Return to the last working directory
4. Cd ~ Return to the Home Directory
5 .! $
! $ Is a special environment variable, which represents the last string of the previous command.
Example:
Download an e-book in chm format:Http://download.csdn.net/source/2843130
Note: I did not write this book. I just compiled it into an e-book for your convenience.
A good definition of an operating system shell is that it is a user interface
Original article:
Http://www.cnblogs.com/serendipity/articles/2133385.html
Http://linux.chinaunix.net/techdoc/develop/2007/08/21/965951.shtml
I. Find Command Format
1. The common form of the find command is;Find pathname-options [-print-Exec-OK...]
Two days ago, I wrote about how to use the host RedHat system to streamline, call, and modify the system to create a tiny Linux of my own!
See: http://blog.csdn.net/wei2856059/article/details/6654801
However, many people are lazy ~~, So I
The current Code only contains the part used to create a file image and generate a file system.
#! /Bin/sh # log = ". /version_make.log "root_path = ". /update_file/network_update "log = ". /update_file/version_make.log "ver_f = ".
1. Conditional Variable replacement:BASH Shell can replace the conditions of a variable. It can be replaced only when a condition occurs.Put the condition in.(1) $ {value:-word}If the variable is undefined or the value is null, the return value is
1. Shift remove the first parameter
2. $ # provides the total number of parameters passed to shell scripts or functions.While [$ #! = 0] gradually decreases with shift $ #, And the loop ends.DoCase $1 in
EsacShiftDone
3. $ *, $ @All command line
The eighth Condition Statement 10.1.1 is a simple if statement $ if 3> 2; then Echo 3; else Echo 2; FI # This is the form of $ cat> test in the command line. sh #! /Bin/shif 3> 2; thenecho 3 elseecho 2fi10. 1.2 use the test format: Test expression
Instance
General programming steps
Now let's discuss the general steps for writing a script. Any excellent script should have help and input parameters. And write a pseudo script (Framework. Sh) that contains the framework structure required by
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