7.1 Creating and executing shell programs 1487.2 Variables 1497.2.1 Assigning a value to a variable 150The shell uses "=" To assign a variable, or you can change or initialize the value of a variable with an equal sign.7.2.2 Access Variable 1507.3
#!/bin/shmkdir /home/zhengyk/desktop/tmp #创建临时文件夹, used to store the extracted files #mkdir /home/ zhengyk/desktop/local #创建临时文件夹, used to store filter results List_alldir () { for file in $ 1/*doif [ -d $file ]; thenlist_alldir
Both Echo and printf in the shell can be used as output, and printf is an enhanced version of EchoShow escape charactersecho \ "Abcdef\" ">>> "ABCdef"Show variablesAge=23echo "My Age is $age">>>my name is 23In the process of use, in order to avoid
1, Shell is the operating system Terminal command line(1) The shell can understand the command-line interface that the software system provides to the user, which can be said to be a way of human-computer interaction.(2) We can use the shell and the
Transferred from: http://www.cnblogs.com/sunyubo/archive/2011/10/17/2282047.html1. Shell to determine the file, whether the directory exists or has permissions2. #!/bin/sh3.4. Mypath= "/var/log/httpd/"5. myfile= "/var/log/httpd/access.log"6.7. # the-
One, for commandIn shell programming, sometimes we need to repeat the command until a certain condition is reached, and the bash shell provides a for command that allows you to create a loop that iterates through a series of values, each of which
What is a shell script, first of all it is a script, and not as a formal programming language, so to speak is that the shell script is a collection of commands.All custom scripting recommendations are placed in the/usr/local/sbin/directory, and the
Variable name: Use English, Numbers and _ (underscore), the beginning can not be a number, length unlimited, strictly case-sensitiveVariable settings: variable name = variable ValueNote: No spaces on both sides of the equals signYou can enclose the
I see Shell the first eye1 , script interpreter settingsfirst line of the script: #!/bin/sh[email protected] sun]# cat test.sh#!/bin/shFirst Firstrows can be split into two parts,#!and absolute paths,#!It's just a special notation,#!The interpreter
1. For command (1) syntax for Val in list; Do commands doneThe list parameter provides some values for the iteration, and the Val value is assigned to the value in list, knowing that the list polling ends.Commands can be one or more
what is a regular expression? Regular expressions are a grammatical rule that describes the pattern of character arrangement and matching. It is used primarily for pattern segmentation, matching, finding, and substitution of strings.two, regular
Although the overall implementation of the automatic installation, but there are many needs to improve the place, such as:1. The code can only be run under the root authority, otherwise it will be wrong, this need to add permission to judge;2. You
There are 2 scripts that run daily on the mission planDTS_RSYNC.SH is responsible for downloading the SQL files that are backed up onlineDTS_INPUT.SH is responsible for importing the downloaded backup files to the local MySQLNow, the problem is that
Prompt effect: Code: # sexy solarized bash prompt, inspired by "Extravagant Zsh Prompt "# customized for the solarized color scheme by sean o ' Neilif tput setaf 1 &> /dev/null; then if [[ $ (tput colors) -ge 256 ]] 2>/dev/null; then
Get the date of the dayDate +%y-%m-%dOutput: 2011-07-28Assigns the current date to a date variabledate=$ (Date +%y%m%d)Sometimes we need to use dates before or after today, so we can use the-D parameter of dateGet Tomorrow's dateDate-d Next-day
Writing the first shell scriptLike other languages, we use any kind of text editor, such as Nedit, Kedit, emacs, vi, etc. to write our shell program. The program must start with the following line (must be in the first line of the file):#!/bin/shThe
Judging variablesRead-p "Input a word:" WordIf [!-n "$word"] ; thenecho "You had not input a word!"Elseecho "The word you are input is $word"FiJudging input parameters#!/bin/bashif [!-n "$"]; thenecho "You had not input a word!"Elseecho "The word
Original:
Http://www.javacodegeeks.com/2013/10/shell-scripting-best-practices.html#BP11
Translation:
Aven
Most programming languages have a series of codes that use this language to follow good programming
ReasonOften we need to find some kind of file and deal with it. For example, locate the. svn folder, and then delete it. If you do not use the shell, you can choose to manually delete, provided that there are few such files, but the SVN information
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