seconds, in the shell script of the usual term loop.At this point, you press CTRL +z to pause it, and then enter BG to go back into the background.In the case of multitasking, if you want to move the task to the foreground, FG is followed by the task number and the task number can be obtained using the jobs command.9. >>, 2>, 2>> : The above-mentioned directional symbols > and >> denote the meaning of substitution and addition, then there are two sym
Shell scripting is an essential skill for Linux OPS engineers and a very important skill, so it's only good to learn shell programming well. Basic grammar I will not speak, learn the C language of these languages, a little bit to understand the basis of shell programming, so we directly cut to the point.The 20th day of
only numbers, letters, or underscores, and cannot start with a number3, as far as possible to see the name of the ideaVI. Bash configuration files1. Profileclass : Provides configuration for the interactive login shell process.• Valid profiles for all users are globally valid:/etc/profile and/etc/profile.d/*.sh• Only the profile that is valid for the current user is valid for the user: ~/bash_profileNote: The function of profile type configuration fi
environmental changes to the parent shell. 2. Use parentheses () Running a command in () also opens a child shell. So do not randomly write () in Linux to change the priority, unless it is escaped, and the parentheses after the turn to have a space between the contents of the parentheses. [Email protected] tmp]# echo $BASH _subshell 0 [Email protected] tmp]# (echo $BASH _subshell) 1 ? Description opens a
out the last/and left string: my.file.txt${file#*.} Take out the first one. And the string to the left: file.txt${file##*.} Take off the last one. And the string to the left: txt${file%/*} take out the last/And right string:/dir1/dir2/dir3${file%%/*} take out the first/and the right string: (null value)${file%.*} take off the last one. And the string to the right:/dir1/dir2/dir3/my.file${file%%.*} take off the first one. And the string to the right:/dir1/dir2/dir3/myTest.sh:File=dir1/dir2/dir3/
been set. [-H file] True if file exists and is a symbolic connection. [-K file] True if file exists and the sticky bit has been set. [-P file] If file exists and is a name pipe (f if O) is true. [-R File] True if file exists and is readable. [-S file] True if file exists and the size is not 0. [-T FD] true if the file descriptor FD is open and points to a terminal. [-u file] True if file exists and suid (set user ID) is set. [-W file] True if file exists and is writable. [-X file] True if file
result is"$sum; Filearray=`ls./files/*. txt '; for file in $filearraydoecho $filedone11. Shake the PanFinally, I wish you ...Because other execution statements can be arbitrarily inserted into the shell script, we can sometimes ask the high-level language or other familiar script to perform some operations. This is where the shell is powerful and flexible.For example, we can write a C + + file#include type
Tags: distinguishing string roo Interactive process%s usage definition function efficiencyFirst, Shell script introductionThe shell is a scripting language, and the shell is a collection of system commands1, can use logic judgment, cycle and other grammar;It's a bit like C language, but it's fundamentally different.2,
command willSHELLmeta-characters are expanded. 4. In the double-brace Test command, if a string (with or without a space) is simply the expression as a normal string, not part of a pattern, it must also be enclosed in quotation marks. If a string value (the one on the right) is not enclosed in double quotes, the string is a pattern, and if it contains SHELL metacharacters, bash expands it. If the string is double-quoted, it is a very ordinary string
substitution or deletion
stty
locale
display locale settings
# Replace the "ABC" that appears in the file with "XYZ"Cat file| tr "Abc" "Xyz"> New_file# Use the TR command to "unify" the case of lettersCat file| tr [A-z] [a-z] > New_fileCat file| tr [A-z] [a-z] > New_file# Replace the number 0-9 in the file with A-jCat file| tr [0-9] [a-j] > New_file# Delete the "Snail" characters that appear in file files
redirect to generate a patch file:[Email protected]:~/dl$ diff-u version1.txt version2.txt > Version.patch[Email protected]:~/dl$ cat Version.patch---version1.txt 2015-12-28 19:16:28.866869790 +0800+ + + version2.txt 2015-12-28 19:17:12.078872041 +0800@@ -1,5 +1,5 @@This is the original text-line2-line3+lin2Line4Happy hacking!+gnu is not UNIXUse the following command to Patch:[Email protected]:~/dl$ patch-p1 Version1.txt Patching file Version1.txt[Email protected]:~/dl$ cat Version1.txtThis is
value of a running process Renice-n PIDNohup SH executes scripts in the backgroundCtrl Z hangs a foreground processFG Job Number The file foreground runs the BG job number to run the file background/proc DirectoryShell Scripts Scripta shell script is a text file that contains a shell directiveShell and oh ah this supports variables with simple syntax to complete batch workHow
function is like a mini script that can be passed when calling a functionAny parameter, within the function is also used to extract parameters such as $, $, $, etc., the position parameter in the function is equivalent to the functionLocal variables, changing these variables does not affect variables such as $, $, $, and so on outside the function. function, you can use returnCommand returns if the return followed by a number represents the exit Status of the function.For example:650) this.widt
No orders found.
128
Invalid exit parameter
128+x
Critical error for Linux signal x
130
Command terminated with CTRL + C
255
Exit status code out of bounds
Exit Exit command can specify exit status code, but not more than 255, otherwise it will be moduloCode 1-16[Email protected]:/data# cat Demo4 #!/bin/bashdateecho $?whoexit 5[email protected]:/data#./demo4 Fri Dec 2 05:03:08 CST 20160root pts/
included file test1.sh does not require executable permissionsRun a python script in a shell scriptTry to run the Python script in the shell script, if the Python script contains the shell's illegal statements, the above mentioned two methods are not possible, this may indicate that the above method is only for Shell script calls. It is also convenient to run Py
variable), returns the old value to the variable after the result has been generated, and then executes the variable plus 1 operation. In contrast, in the prefix (prefix), the operand is placed in front of the variable, the variable is added 1, and then return the new value to the variable,--the working method and + + is similar, but its operation is to reduce the variable by 1.7. Exit statusEach command exit returns a small integer value to the program that refers to it, which is the well-know
Tags: shell script1, write script/root/bin/systeminfo.sh, display the current host system information, including hostname, IPV4 address, operating system version, kernel version, CPU model, memory size, hard disk size#!/bin/bashecho "hostname: `hostname`"echo "ipv4 addr: `ifconfig |egrep -o "\2, scripting/root/bin/backup.sh, can be implemented to backup/etc/directory to/ROOT/ETCYYYY-MM-DD#!/bin/bashecho "co
-be-sustained by perpetual neglect of many and other things. Robert Louis Stevenson (1850-1894)
[Email protected]:~/shell/26zhang$
Note this:#grep "$ (date +%b '%-d, '%Y)"-A2 |Since my Ubuntu is in Chinese, I have not been searching for November. I'm going to replace it with this one, only 28, 2017.grep ", $ (date +%y)"-a2 | # Xcy AddIt would have been like this grep "$ (date +%-d, '%Y)"-A2 | # xcy Add, don't know why my date is 29. And the site is
Bash shell scripting Getting Started (ii)Use of the Read commandRole:Use read to assign the input value to one or more shell variables:-p Specifies the prompt to display-T TIMEOUTRead reads the values from the standard input, assigns a variable to each word, and all the remaining words are assigned to the last variableEx.read-p "Enter a filename:" FILE650) this.w
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.