█ Start line The shell program must start with the following line (must be in the first line of the file)#!/bin/shThe symbol #! is used to tell the system that the parameter behind it is the program used to execute the file █ executable when editing
The shell implements the trim function effect to remove spaces on both sides of the string, and the following three commands are equivalent, all of which can be implementedSed ' s/^\s*//' totrim.txt |sed ' s/\s*$//' >trimed.txtSed ' s/^\s*//;s/\s*$//
1. Date:show current date and time.2. Cal:calendar.3. df:to see the current amount of free space on your disk drives.4. Free:show The amount of the free memory (if using this command at Cygwin, CROCPS package should has been installed Fir ST).5.
Create 20 users with shell script, ask 20 users to specify the home directory as/share/home/, and give each user randomly assigned a password, and finally record these user information in the log![[email protected] sbin]# vim 2.sh mkdir -p
Eight, shell script sed&awk01.sed using the Flow editor-steam editor#ed/etc/passwd1,10p ... 1s/root/byf/p (replace root for BYF) #sed-E ' s/root/byf/g '/etc/passwd (function as above) just show the content change #sed-e ' s/root/byf/g '/etc/passwd >/
Come to a domain name how to determine its cache or not, the high-level professional crawler can certainly do analysis, if not very rigorous analysis, through the shell script can also be implemented, to see me this layer of pages of small crawl bar,
The IF in [] is actually called a quick method of test. Bash's numeric and string comparison operators:
Note = spaces on both sides
String
Numerical
is true, if
x = y
X-eq y
[email protected] ~]$ cat test1.sh#!/bin/bashecho "What is your operating system?"Select Os in "Linux" "Unix" "Mac" "Windows"DoBreakDoneecho "Your operating system is $os"[[email protected] ~]$./test1.sh #? Subsequent numbers require manual input by
For example, there is a file Test.txt, which contains this data.meiguounix232FaguounixRibenunixZhongguounixtaobaoHanguounixbabaNow I want to intercept Unix in front of the data, including UNIX, and output.The data to be obtained should
Shell study1. Exit StatusIf the command executed successfully (or true), the value of $? is zero. If the commandfailed for some reason,$? Would containapositive integer between 1 and 255, inclusive. A failed command usually returns 1.2, testing an
1:grep Command:Grep-v "char" file_name matches text that does not include "char"Grep-n-W "char" file_name complete match for a charactergrep ^s $s are text that matches the beginning of s or the end of the line as S.2:TR commandTR Set1 Set2 Replace
A simple shell script
A simple shell script to writeSuppose I want to know how many people are currently logged on the system, and use the who command to tell you who is logged in to the system now:1.[[email protected] ~]$ who2.KANO
Output redirectionThe syntax for command output redirection is:Command > file or command >> fileIn this way, the contents of the output to the display can be redirected to the file. If you don't want the file content to be overwritten, you can use >>
Nonsense not much to say, directly on the code, the basic implementation of subtraction functions:#!/bin/bash# author by alsww# date : 2016.02.03# mail : [email protected]# blog : alsww.blog.51cto.comprint_info () { printf " Please enter the
Conditions= equals applies To: integer or string comparison if in [], only the string! = is not equal to: integer or string comparison if in [], only the string-eq equals applies To: integer comparison-ne not equal to: integer comparison-lt less
The hill sort was proposed by D.l.shell in 1959, and the relative direct ranking has been greatly improved. Hill sort is also called narrowing the incremental sortBasic idea:First, the entire sequence of records to be sorted into a number of
PrincipleDivides the sorted array into sub-sequences (this depends on the originally set step value), then inserts the sequence directly between the individual sub-sequences, and then the increment (that is, the step value) and then inserts the sort,
Shell scripts are powerful and simple when working with text and managing the operating system.Combining shell scripts into your application is a great way to quickly implementThis article describes the use of Java code to invoke and execute the
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