Commands frequently used in the shell for regular expressions include grep, sed, awkThe contents of the file used for testing[email protected] ~]# VI testfileCurrent Network StatusLast Updated:mon Feb 10:55:06 CST 2016Updated every secondsNagios
Shell-related usageIf usage-Q does not output results, only make judgments[Email protected] tmp]# if Grep-q ' ^daixuan: '/etc/passwd; Then echo "Daixuan text"; fi, when/ETCPASSWD contains Daixuan, the output Daixuan testCase usage[Email protected]
Cat /etc/passwd All system user accounts list and basic information for each user cat/etc/meminfo the current state of the virtual memory ipcs-m View the Shared memory page on the current system [[email protected]~] #当前shell的用户名, current
Today is WebSocket,Complete the getops of a shell first, Monday will be useful.#!/bin/BashEcho "usage:./$0-T (prism|opscripts)"functionscp_prism () {Echo "scp_prism ()"}functionscp_opscripts () {Echo "scp_opscripts ()"} whilegetopts t:h OPT Do
First, write shell scripts to add users in bulkImplementation method: To determine whether the user exists, there is a return error prompt, while determining whether the user file exists, does not exist then exit1. Create Add User Script[Email
#shell特性| Pipeline> Redirection>> Chasing heavier orientation2> Error Redirection2>> Append Error redirection#作业控制CTRL + Z to temporarily stop the jobJobs View JobFG recalled to front desk+ Higher PriorityFG 2 designated number recallBG tuned to
1.Shell programming As with Java, PHP programming, as long as there is a code to write a text editor and a can explain the execution of the script interpreter can be#!/bin/sh (#! tells the system that the program specified after the path is the
First, FTP download the current file according to the date#!/bin/bashdate= ' Date +%y%m%d ' ftp-n Second, upload the current file according to the log#!/bin/bashdate= ' Date +%y%m%d ' ftp-n Three, more and catalog upload download#!/bin/bashdate= '
The process controls the "if" expression if the condition is true then the following part is executed: if ...; Then....Elif ...; Then....Else....FiIn most cases, you can use test commands to test the condition. For example, you can compare strings,
First create the name myfuns# My script functionsfunctionAddem {Echo$[ $1+ $2 ]}functionMultem {Echo$[ $1* $3 ]}functionDivem {if[ $2-ne0 ] Then Echo$[ $1/ $2 ] Else Echo-1 fi}Then create a script with the name: test14. SH #!/bin/bash#
[email protected] ceshi]# cat test.sh#!/bin/bash# test.shecho "-------------ISF is set to \"-seperator\ "------------"Ifs= "-seperator"; # Note that there is a minus sign (-) before SeperatorFor i in "[email protected]"; Do echo "@ ' $i '"; DoneFor
Format: Test conditionString test: Note space: Test STR1 = = STR2 Tests if string is equal test str1! = str2 test string is not equal test STR1 tests if string is not empty test-n str1 test string is not empty test-z str1 Test whether the string is
From Shell13 asked-E: Activate the conversion of the backslash control character (refer to the following table)-e: Turn off anti-skew control character conversion (preset)-N: Cancel line end of line symbol (with the \c character under the-e
Method Two/sbin/ifconfig-a|grep inet|grep-v 127.0.0.1|grep-v Inet6|awk ' {print $} ' |tr-d ' addr: 'Method OneGet the native IP address and save it in a variablearg=ifconfig eth0 |grep "inet addr"| cut -f 2 -d ":"|cut -f 1 -d " " Ipaddr=
a
Next look at some special variables$? : Receives the return status code of the previous command, so that you know whether the previous command was successful,If the previous command succeeds, the return status code is 0, and if the previous command
Hill sort (Shell sort)#include using namespace Std;void print (int a[], int n, int i){Coutfor (int j= 0; j{COUT}cout}/* Direct insertion of the general form of the sort ** d Zoom out increment, if is direct insert sort, d=1 */void Shellinsertsort
The shell is much more programmatic in terms of programming than Windows batch processing, both in loops and operations.Bash supports one-dimensional arrays (which do not support multidimensional arrays) and does not limit the size of arrays.
[Basic ideas]Group records that originally had a large number of records. Cut into a number of sub-sequences, at this time each sub-sequence to sort the number of records is less, and then in these sub-sequences are directly inserted in the order,
Linux Shell variables and linuxshell Variables
M @ meng :~ $ B = 2 + 3 m @ meng :~ $ Echo $ b2 + 3
However, the declare command can be used to set the type of a variable. Currently, only integer and array types are supported. Now, consider
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