If the variable is null, you can use: = to set a default value. Syntax:
$ {Var: = defaultvalue}
Example:
Enter the following command in terminal:
Jubincn @ Ubuntu :~ $ Echo $ {Bank: = ICBC} icbcjubincn @ Ubuntu :~ $ Echo bankicbcjubincn @
Not comprehensive but practical.
1. xargs -- pass the output of one command to another
1.1 Find./modules/-name *. So | xargs CP-T $ {packdir_so }/
Output find to CP as the Source Parameter
-T specifies the target path of the CP.
2. Date =
A classic debugging method in shell scriptsAuthor Yu Chao Email: yuchao86@gmail.com
The common method for testing shell scripts is to use echo to output data to check whether the data meets the requirements.ProgramThe value of the operation.If the
Preface: Do not ask why you need to configure the network in Shell (command line) when the desktop system is popular. If you have any questions, please stop reading this article.
$ Iwlist wlan0 scan # list valid Wireless Networks$
1. For and if commands containing [] must be separated by spaces.
2. Calculation and Assignment Methods
Var = 1 (Note: Bash/pdksh cannot leave spaces on both sides of the equal sign)
First: (VAR ++ ))
Type 2: var =$ ($ var + 1 ))
3.
From: http:// OS .51cto.com/art/200912/165925_1.htm
Location Parameter $1, $2 ,..., $ N, $ # represents the number of parameters in the command line, $0 represents the Script Name, the first parameter represents $1, the second parameter represents $2
This book has been read and written before. It is good to read again to deepen your memory.
Chapter 4 file security and permissions
1. directory permission bit
The directory permission bit is different from the file. The read permission bit of the
Example
Ls-L> out. File 2> & 1 &
Explanation:Ls-L> out. File // redirects ls output to file out. File
2> & 1 // in shell, the file descriptor is usually stdin, stdout, stderr, I .e., 0, 1, 2. It can be seen that it uses LS-L> out. the error
Official Website:
Http://intgat.tigress.co.uk/rmy/extensions/index.html
The extension has the following functions:
Move the clock to move the time to the right
Favourites in panel displays shortcuts for your favorite programs on the top
Usage of Linux Shell scripts in character Text Processing
Author: Yu Chao email: yuchao86@gmail.com
Shell may not be as powerful as perl, but it is also very useful for some special purposes.
Let's look at the following example:
[Yuchao @
Conditional expression:
1. File expression
# If the file exists if [-f file] # if the directory exists if [-d dir] # if the file exists and is not empty if [-s file] # if the file exists and is readable if [-r file] # if the file exists, you can
I have been idle for the past two days, playing Nb, starting with shell, and coming up with something interesting. Remember it by the way.
A simple script test_2 is written to output the user's parameters:#! /Bin/shIf [$ #-lt 2]; thenEcho "you need
IBM engineers have written these articles too well. I really want to copy them all. It's a bit lazy, and the whole link has been directly connected. Haha.
The essence of awk:
Awk instance, Part 1-an excellent language with a strange name
Awk
The basic structure of until is:
Until [condition]; do
Logic
Done
The code I implemented is as follows:
Sum = 0; n = 3; in = 0;Until ["$ n" = 0]; doRead inSum = 'expr $ sum + $ in'N = 'expr $ n-1'DoneEcho $ sum
The basic structure of a for loop
Shell:
#! /Bin/bash #=============================================== ====================================## this example show you how to get data from pipe #====== ========================================================== =============== while
Operator
Description
Example
File comparison operator
-EFilename
IfFilenameYes, true
[-E/var/log/syslog]
-DFilename
IfFilenameIs a directory, it is true
[-D/tmp/mydir]
-FFilename
IfFilenameIs
> Append
> Overwrite
> & Set the previous storage location to the next storage location
P.S.: Of course, there is still an inverse
0 standard input
1 standard output
2 standard errors
Example:
ls /usr/tmp 2> err.file
Write the error generated
Text and graphics interfaces
Dialog is a tool used to create a dialog box in shell script. You can use dialog to create different information and problem windows to facilitate the script.
Dialog creates a text interface in terminal mode, and a tool
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