Shell intercepts the content between the specified strings

#!/bin/bash#截取字符串#path =ss/usr/share/src/root/home/adminPath=ss/usr/share/src/root/home/admin/src/addEcho $pathEcho ${path%src*} #从右向左截取第一个 the string after SRCEcho ${path}Echo ${path%/*} intercepts the first/second string from right to leftEcho

Shell Daily Script

1. Use a command to find the files that have been modified in the last 24 hours in the/etc/directory, and the suffix name isthe. log file and delete it.Find/etc-type f-mtime-1-name "log* "-exec rm-rf {} \;2. From the Test.log file, find the row

Methods for referencing shell variables in awk code

A fragrant chestnut is better than words#!/bin/bashfoo= "Good" # Without spaces bar= "Hello World" # with spaces awk ' BEGIN {print ' $foo ' "; "'" $bar "'"} 'The pest above maintains the usual practice of enclosing the awk code in single

Process Control keywords in the shell

If...elseif [$1x = = "AB" x]; Then echo ' You had enter AB ' elif [$1x = = ' CD ' x]; then echo ' You had enter CD ' Else echo ' You had enter UNEXPE CTED word "fi  Case...esacA switch case similar to another language, however, here is a

Shell script Linux Commands execute continuously

Three ways the shell command executes continuously:1, command 1; command 2; command 3Executes the command sequentially, regardless of whether the previous command executed successfully.2. Command 1 && Command 2 && command 3The next command is not

Shell Programming-Basic syntax

Tag: element represents article string output shard for form berThe role of variablesForbidden spaces on both sides of the equals signFor loop#语法一 for variable in value 1 value 2 value 3 : Do block done # #语法二 the for variable '

Basic usage of strings in the shell

ObjectiveToday, when writing a script, found that the previous phase used some of the usage is still need to go to Baidu Search, and find the answer also need to filter, delay writing script time, this article on the comparison between the string

The difference between ${} and $ (()) in shell scripts. ${} Qualifying variable Boundary $ (()) subtraction operation

1. ${ }A more precise range of defined variable names is used for variable substitutionFor example:A=bEcho $ABOriginally intended to replace the result of a $ A and then a B-letter followed, but on the command line, the real result is only replace

Shell writing character Menu Management-8

8th Shell Programming Character Menu ManagementI. Shell function definitionFunction menu () {Echo ' This is a func!! ';}Two. Shell functions useMenuThree. How to use the Cat command HeredocCat

Calculate two time difference with Linux shell

1, there are two records in the logID Start time End time0dedffee485e7ddbbff1236cfc0d91 2018-06-28 16:55:37 2018-06-28 16:55:52122dw049dc21b0a7dcdfegeat8c8 2018-06-28 17:21:01 2018-06-28 17:21:23How can I use the Linux shell command to calculate the

MacOS Shell Programming Notes

2. MacOS does not support ll (need to use LS-L implementation), in fact ll under Linux is ls-l shortcut keys.LS Displays the file in the current directory.LS-L Displays the file details in the current directory.#以下命令均不包含 ".", "..." Directories, and

Linux--shell Programming Basics

There are two types of programming languagesStrong type: such as C language. The data has a specific type that is declared before it can be used. Data operations must conform to type requirements (e.g., string type data cannot be arithmetic directly

Initial construction of Jumpserver with Shell

#!/usr/bin/bash#jumpserverTrap "" HUP INT ouit TSTPClearWhile:DoWebserver=192.168.117.101mysql=192.168.117.102Cat 1.WEB2.MYSQLEofRead-p "input number:" numCase ' $num ' in1) SSH [email protected] $webserver;;2) SSH [email protected] $mysql;;*) echo "

Shell Basics (1)

Shell Basics1.shell is the intermediate medium used when the system interacts with the computer hardware, and he is a system tool. If the computer hardware analogy to the human "body", the system kernel is the human "brain", the shell is the "five

Shell determines memory usage alarm

#!/usr/bin/bash#########################################memory used#v1.0 by LIXIN 20180605########################################Mem_used=free -m |grep ‘^Mem‘ |awk ‘{print $3}‘mem=free -m |grep ‘Mem‘ |awk ‘{print $2}‘mem_usage=$

Lab Four Shell Programming 2

1. basic usage of shell variables and usage of common symbolsThis section requires writing out the shell commands that implement the requirements , showing(1) Change the main prompt to the user's home directory name( Hint: reference material 4.6.8

Shell Display-bash-4.1# Workaround

When operating on SECURECRT, do the following carelessly:?????????????????? [[email protected] ~]# echo "Alias rm= ' echo this command does '" ">. Bash_profile?????????????????? [[Email protected] ~] #source. bash_profile?????????????? When the

Disable and drop cannot be executed in hbase shell

1 Querying work status through the Web monitoring page of HBase discover the regions in transition area has a long-running task, you need to close Hbase-master and restart, and then this problem process I directly use/etc/init.d/ Hbase-master restar

Shell script: Add new rows to another file

#!/bin/bashCd/usr/local/logstash/nginxlog[-F Num.txt] | | Count=0[-F Num.txt] && count=cat num.txtNcount=wc -l /var/log/nginx/access-app.log | awk ‘{print $1}‘echo $ncount > Num.txtFor ((i= $count +1;iDoNum=$[i]plog=sed -n $num /var/log/nginx/access-

Functions, arrays in 71.shell

One, the function in shell script? The function is to organize a piece of code into a small unit, and give the small unit a name, when the code is used to call the name of the small unit directly.Format: function F_name (){command} function

Total Pages: 541 1 .... 434 435 436 437 438 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.