12. Sort commands for Rowssort:1. Sort command-line options:
Options
Describe
-T
Separators between fields
-F
Ignore case when sorting based on character
-K
Define
File expression-e filename true if filename exists-d filename If filename is a directory, true-F filename True if filename is a regular file-L filename True if filename is a symbolic link-r filename If filename is readable, true-W filename if
There are two ways to represent logic in bash:(1) [$state = = "Running"-a $name = = "Zone1"](2) [[$state = = "Running" && $name = = "Zone1"]]The second type is supported in Ksh.Instance:#! /bin/-P "pelease input your name:"-P "pleaase Input your
Common commands· LS View the files in the current directory· CD into a directory· CD-Jump back to previous directory· CD ~ Enter the current user's personal directory· PWD Output Current path· mkdir new Folder· Touch New File· Find File· ln
#!/bin/sh mypath= "/var/log/httpd/" myfile= "/var/log/httpd/access.log" #这里的-x parameter Judging $ Whether the MyPath exists and has enforceable permissions if [!-X ' $myPath]; then mkdir "$myPath" fi #这里的-D parameter to determine if
1, test-f file 2, [-F file] 3, [[-F file]][-F file1-a-F file2] logic with [-f file1-o-F file2] logic or [-f file1] && [-f file2] the same as a string operation best double quotes such as-n-z = = = And a space is added to both sides of the equals
(1) Command1;command2Use ";" , the Command2 is executed regardless of whether the Command1 executes successfully.(2) Command1 && Command2When you use &&, Command2 is executed only if Command1 executes successfully, otherwise Command2 does not
Write a script, create a folder, enter a folder, and then use the loop to create a sequential file in the folderIdea: 1. Create the specified folder and go to the folder2. Specify a variable with a value of 0 to allow this variable to be recycled3.
The shell file containsThe shell can also contain external scripts in the following syntax format:. FileNameOrSOURCE filenameFor example, create a two shell script.Script 1:test1.sh
url = "Www.baidu.com"
Script 2:test2.sh
.
Getting started with Linux shell scripts--cut commandCutThe Cut command extracts text columns from a text file or text stream.Cut grammar[[email protected] ~]# Cut- D " Delimited character " -F fields for having a specific delimiter character [[
1.HELP displays a list of all built-in commands, or the use of a built-in command
#help//View all built-in commands
#help built-in commands//view built-in command usage
#help-S built-in command//display the syntax format of the
First, prefaceAs is known to all, Jenkins can implement project updates by default (via SVN, but our company uses git), and projects are released through (Maven plugin), but in this case under some containers (such as Tomcat), The JVM will report
You must enclose all the file names you get into the array, or the for loop will be parsed as a wildcard, or you can use a shell dictionary, as well as quotation marks.Shell Dictionary Example#!/bin/BashEcho "Shell Definition
#!/bin/Bash#defind the Pathpath=/usr/Localexport Pathread-P"Please input your first name:"Firstnamereap-P"Please input your last name:"LastNameEcho-E"\nyour name is: $firstname $lastname"#useDateCreatefileRead-P"Please input your
The problem has been a long time, and has not been sorted out. Remember the last interview when asked how to bulk modify the host name of 1000 machines. Here is a file named 1.txt that is created in bulk for hello.First, install the expectYum
4.1.3 Shell Process Control Statements If condition judgment StatementIf ( expression ) #if (Variable in Array)Statement 1ElseStatement 2FiCase one, test if the directory exists, does not exist then new (note that space must be between the brackets)
Environment variables in the shell become global variables and local variables. Global variables take all caps.1.printenvView the global variables for the system.Displays the value of a single environment variable using the echo command.Eg:echo
1, Tail-f/var/log/secureYou will find a lot of login errors. This means that your machine is being violently cracked.2. Create a new shell scriptSave exit.3, join the timing CRONTAB-EI'm judging every 10 minutes here, you can put a little longer.4.
Today in the shell script to write Fibonacci sequence calculation, has been constantly error, the main reason is because the shell script is too intelligent, in the array operation need to write a lot of symbols, it is easy to confuse, so a little
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.