1, get the character from the front 8, the implementation method is as follows:a=123456789$ expr substr $a 1 8$ echo $a |cut-c 1-8echo $$ echo $a |dd Bs=1 count=8 2>/dev/null2. Interception by the specified string(1) The first method:A string after
Echo ' $ Get the file name of the currently executing shell script: ' $Echo ' $n gets the nth parameter value of the currently executing shell script: ' $ ' =$1 ' $ =$2 ' $ ' =$3Echo ' $* gets all the parameters of the currently executing shell
#!/bin/bash#created: 2017.07.21#author: molewan#description: help erp app upgrade ########################################################## #脚本说明 ################################## ######################### #a, copy the data that needs to be added
Input/Output
Display on the monitorRedirect to FileStandard file descriptor0 STDIN Standard Input1 STDOUT Standard output2 STDERR standard error redirect error message when you need to develop a file descriptor Ls-al badfile 2> test11111Ls-al
Write shell scripts Common sh test.shThe notation of-M 2-d 3Case script:#!/bin/bashwhile getopts ": a:b:c:" Arg #选项后面的冒号表示该选项需要参数doecho "arg": $arg case $arg in a) echo "a ' s ARG: $OPTARG---$OPTIND "#参数存在 $OPTARG
The landlord encountered a scene like this:Execute a script locally, log on to the server, but the login server requires a password to implement the password manually in the scriptThe function of EOF can be achieved by:ssh [Email protected] 192.168.
Description: Adds a user name and password through a script, and discards the add if the user name already existsScript Name: test2.txtCd/optlsmkdir SHELLLSCD SHELLLSVI Test2.txtThe script reads as follows:#!/bin/bashid $ &>/dev/null && echo "User $
Today the weather is cloudy, a little bored, so boring to play like ...#!/bin/bash#date:2017-6-20#version:1.0#author:xcn ([email protected]) menu () {Cat This article is from the "Little Rookie" blog, please be sure to keep this source
Positional variables
$ $ Gets the file name of the currently executing shell script, including the script path if the script is executed with a path[[Email protected] shell]# sh n.sh n.sh[[email protected] ~]# sh/shell/n.sh/shell/n.sh[[email
& placed after the startup parameter to set this process as a background processBy default, the process is the foreground process, then the shell is occupied, we can not do other operations, for those who do not interact with the process, many times,
Create the user who wrote the file650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/98/E0/wKiom1lBR5_gYB4HAAAoKuZARYU671.png "title=" Screenshot from 2017-06-13 19-44-27.png "alt=" Wkiom1lbr5_gyb4haaaokuzaryu671.png "/>Second, ping 172.25.2
0--stdin Standard input1--stdout Standard Output2--stderr standard Errorredirectecho "This was a good idea" > Temp.txtTemp.txt content will be emptied first before entering "this is a good idea"Additionalecho "This was a bad idea" >> temp.txtCat
grep: For fuzzy lookups, in standard input or file Format: grep [option parameter] ... PATTERN | FILE ...Option parameter Description:- E,--extended-regexp PATTERN is an extensible regular expression-E,--regexp=pattern using PATTERN for matching
Shell scripts can be directly./**.sh, or bash **.shI use the./**.sh to run a script of my own, and the following error will appear:[Email protected]:~$./pixel. SH bash:. /pixel. SH : Insufficient permissions [email protected]: sudo ./pixel. SH
The folder does not exist and is createdif [!-d "/data/"];thenmkdir/dataelseecho "folder already exists" fiFile exists then deleteif [!-F "/data/filename"];thenecho "file does not exist" Elserm-rf/data/filenamefiDetermine if a folder existsIf [-d
$ $1-n The name of the current shell script the position variable $ #参数的数量 $* the value of all positional variables #? To determine whether the previous command succeeded, 0 for success, The non-0 is the failure---------------------------------------
Shell Application TipsThe shell is a command interpreter, a layer of interaction between the kernel and the kernel. There are many kinds of shells, the one with the prompt that belongs to /bin/bash, and almost all Linux Systems default to this shell.
From Wang Yin: the flaw of UnixI would like to explain my understanding of the nature of Unix philosophy through this article. While I point out a design problem with UNIX, the goal is not to attack the interest of UNIX. Although Unix has a very
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