Recently the system has learned shell programming.See an example in the book, very dick. I thought about it before, but I didn't get the result.I believe that the students also guessed this example, is a line of string splitting. Students can try it
String manipulation${#string} The number of characters in the output sentence${string:position:length} output $position The length of the start of the character${string:position}[[email protected] scripts]# liuyifei=] i like sanpan i like luo
It has long been assumed that the export-after variables in the shell script will affect the environment variables in the terminal that executes the shell. The concept of environment variables is not unique to the shell, but is owned by the process
1 loops (Command execution ... But the parameter will change)As in the following form:#!/usr/bin/env bash#encoding=utf-8a= "Value1value2value3value4value5value6" for I in $ado echo "cmd $i argv" doneNote: $a cannot be written as a "$a", otherwise it
Little brother just contact Linux, a lot of things on Linux is more unfamiliar, so write a blog, as their work summary and technology accumulation bar, but also spur their efforts to learn.The reason for today's title is to put Export,source, Bash's
Double quotesPurpose: In order to contain text or function segments. In addition to itself, the function inside the counter-quote, the variable starting with $ and \ Start the inverse of the character outside, the rest are directly output.The
1. Conditional selection: If statement① Single Branchif judgment condition; then condition is true Branch code FI② Dual Branchif judgment condition; Then condition for true Branch code else condition for false Branch code FI③ Multi-Branchif judgment
Today, when I write a shell script, I find that debugging will make a mistake.[Email protected] autoawrrpt]$. a.sh dirname: Invalid option--B Please try to perform "dirname--help" for more information. BaseName: Invalid option--B Please try
Syntax: eval cmdlineEval will scan the back of the CmdLine two times , if after the first scan, cmdline is a normal command, then execute this command;If the cmdline contains an indirect reference to a variable, the semantics of the indirect
One: RANDOMEcho $RANDOMRandom number is a range of 1--32767, generally used it can be cracked1.2 Generate a eight-digit random password:echo $ (($RANDOM +11111111))Two: Md5sum random encryption method generates a longer passwordTake 9-digit password:
Look at a little script#!/bin/bash#demonstarting the shift commandcount=1while"$" Do "Parameter # $count =$1" Count 1] ShiftdoneechoechoThe script first tests whether the first parameter exists as- n "$" , prints if it
Answer reference:Suppose there are variablesvar=http://www.oldboyedu.com/123.htm.1. # Intercept, delete the left character, leave the right character.Variable: Var=http://www.oldboyedu.com/123.htmecho ${var#*//} where Var is the variable name and
Variable Description:$$The PID of the shell itself (ProcessID)$!PID of the Shell's last running background process$?End code of the last Run command (return value)$-Flag at a glance using the SET command$*All parameter lists. such as "$*" in the
The main purpose of the script is to practice capturing signals in a Linux bash script, by practicing the use of functions, and by terminating a running program, subsequent processing of files opened by the program, and so on!Scripting Features:Ping
The main purpose of the script is to practice capturing signals in a Linux bash script, by practicing the use of functions, and by terminating a running program, subsequent processing of files opened by the program, and so on!Scripting Features:Ping
In writing shell scripts, we need to use a variety of special symbols, through these special symbols can make the code we write more concise and efficient, here are summarized below:1. {} curly braces:Usage One: Wildcard extensionEg:ls
I. Functions in the shell[Email protected] aming]# cd/root/shell/aming[Email protected] aming]# vim fun1.sh//need to be aware that function names cannot conflict with some keywords in the shell#!/bin/bashfunction InP () {Echo $ $ $ $#}INP 1 a
usage: seq [options] ... Mantissa or: seq [options] ... First number mantissa or: seq [options] ... The first number increment mantissa Prints the number to the mantissa starting with the specified increment from the first number.
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.