linux shell scripting cookbook

Alibabacloud.com offers a wide variety of articles about linux shell scripting cookbook, easily find your linux shell scripting cookbook information here online.

"Linux command line and Shell Scripting Encyclopedia" chapter 26th some interesting scripts

-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

Program Ape (yuan) one of the essential skills of shell scripting: How to automatically back up MySQL data under Linux

/etc/crontab Add the following code: Here's an example of an hourly 26-minute execution: * * * * * root/home/**/wewang/autobackupmysql_qas.sh If executed at three O ' Day, then: XX 3 * * * root/home/**/wewang/autobackupmysql_qas.sh Case 2:redhat situation. ( that is, the currently used Linux system ) Copy the script you just edited to the appropriate directory [Email protected]***** wewang]# CP autobackupmysql_qas.sh/etc/cron.da

Linux Shell Advanced Programming Tips 3----Run Level scripting Introduction

file is a script that is executed when the Linux system startsEdit the Inittab file (use the Vim/etc/inittab command to open the file)Example: Add a statement to the Inittab file to allow the system to execute a shell script file that checks the system disk when it starts checkdisk.shcheckdisk::once:/sbin/checkdisk.sh >/dev/console 2>1 indicates that this command is executed at each runlevel, if it is to b

Linux Learning-Advanced shell scripting (a) function

, which is represented as a local variable. such as local temp=1 .Example 3. Array Parameterstest3.sh#!/bin/bash Span class= "hljs-comment" ># trying to pass a array variable function testit {local newarray # use ' local ' define a local variable newarray= (' echo " the NewArray value is ${newarray[*]} "}myarray= (1 , 2 , 3 , 4 , 5 ) echo "the original array is:${ Myarray[*]} " testit $myarray Test:sh test3.shOutput:The original array is:1,2,3,4,5The NewArray value is 1,2,3,4,5Example

"Linux command line and Shell Scripting Encyclopedia" chapter Fourth

fileYou can also connect many parameters.such as Sort-t ': '-K 3 testYou can think of it as something inside. xxx1:xxx2:xxx3:xxx4:xxx5means to sort the xxx3-T: Specifies a character to distinguish the key position-K:--key=pos1[pos1]. The sort starts with pos1, and if POS2 is specified, it ends at Pos2.| Redirects the output of the du command to the sort command.-r: Indicates descending order.Here is an example:4.3.21. grep [options] pattern [file]For example:grep t test//Search for text in test

LINUX Shell Scripting related

instruction (displays the exit status of the last command. 0 means no error, any other value indicates an error)$-shows the current options used by the shell, same as the SET command function[email protected] is similar to $*, but can be used as an array--------------------------------------------------------------------------------------------------#!/bin/sh##############Export lang= "ZH_CN. GB18030 "Export JAVA_HOME=/USR/LOCAL/JDKExport path= $JAVA

The tenth chapter of the Linux command line and Shell scripting Encyclopedia uses the editor

Previous Edit CommandA: Append data after the current cursorO: The next line of the cursor inserts dataDW Delete a Wordd$ Delete to end of lineDD: Delete Row, 5dd delete 5 rowsThe use of backspace and delete keys in normal mode is not recognized.10.1.4 Copy and pasteDD can be pasted with p after deletion.The copy command is Y,YW copy a wordy$ Copy to end of lineThen use p to paste10.1.5 Find Replacement: s/old/new/g a line command to replace all old, which is replaced only on one line: N,ms/old

Getting Started with Linux Shell scripting (ii) Looping statements

sundo Echo ' Today is $var 1 ' donefor var2 in {1..10..2}doecho ' this is $var 2 "Donefor Var3 in $ (SEQ 1 2) Doecho" I had a/an $var 3 "Donefor VAR4 in $ (LS) Doecho" Here's the file $var 4 "doneWhile loop#!/bin/bashi=1while ((I SELECT statementThis SELECT statement to the time the wood has seen, run when you can interact with the user, run the following program to understand. If you don't break it, you're going to die.#!/bin/bashecho "which color do you like?" Select Var1 in red Green Bluedoe

Shell scripting exercises for Linux

A. Triangle Square exercise1. Print triangles, method one, regular expressions650) this.width=650; "src=" Https://s3.51cto.com/oss/201711/21/ea1ad50480c4e888094441dee06b962f.png "style=" float: none; "Title=" screenshot from 2017-11-21 21-34-44.png "alt=" Ea1ad50480c4e888094441dee06b962f.png "/>Method two, loop nestingI control lineJ Control Printing symbols650) this.width=650; "src=" Https://s3.51cto.com/oss/201711/21/e08401143190fdb2eb60e1ef084e1528.png "style=" float: none; "Title=" screensho

"Python Cookbook" "String and Text" 3. String matching using shell wildcard characters

handle non-file-name strings.#example.py##Example of using Shell-wildcard style matching in list comprehensions fromFnmatchImportFnmatchcase as Matchaddresses= [ '5412 N CLARK ST', '1060 W ADDISON ST', '1039 W GRANVILLE AVE', '2122 N CLARK ST', '4802 N BROADWAY',]a= [addr forAddrinchAddressesifMatch (addr,'* ST')]Print(a) b= [addr forAddrinchAddressesifMatch (addr,'54[0-9][0-9] *clark*')]Print(b)>>> ================================ RES

Linux redirection related (reprint post, for yourself Cookbook)

string-S: Replace duplicate characters!Example: [Root @test/root]# Last | TR ' [A-z] ' [A-z] ' [Root @test/root]# cat/etc/passwd | Tr-d: [Root @test/root]# Cat/home/test/dostxt | Tr-d ' \ r ' > Dostxt-nomSplitSyntax: [Root @test/root]# split [-BL] input file output file leading characterParameter description:-B: Divide by file size-L: divided by the number of rowsExample: [Root @test/root]# split-l 5/etc/passwd test Description: It's a lot easier under Linu

Shell Script Programming Learning Note-shell Scripting Basics Introduction

files under/var/logPut all the commands in one file and build up the script, here is the simplest command to stack up the script, empty the log script.Cd /var/logCat /dev/null > messagesEcho “Logs cleaned up.”Expand: Three ways to empty logs and file contents[[emailprotected] ~]# echo >test.log [[emailprotected] ~]# >test.log [[emailprotected] ~]# cat /dev/null >test.logScenario: Preserve files and empty content.Two Shell language and category Introd

What is a shell? Shell Scripting Basics Detail _linux Shell

, and the shell interprets the execution.• Batch processing (Batch): The user writes a shell script in advance, with many commands that allow the shell to execute the commands one at a time without having to hit the command one by one. Shell scripts and programming languages are similar, there are variables and proces

Eight reliable recommendations for Shell scripting (worth collecting) _linux shell

These eight suggestions derive from the experience and lessons learned from key writers who have been writing shell scripts for several years. In fact, began to write more than these several, and then pondered repeatedly, remove a few insignificant, finally left eight. It is no exaggeration to say that each is a carefully chosen one, although a few are commonplace. 1. Specify bash The first line of the shell

Shell scripting 30 minutes to get started

-rwxr-xr-x 1 root wheel 1103984 6 Nov 16:52 /bin/zsh Advanced programming languages In theory, as long as a language provides an interpreter (not just a compiler), the language is capable of scripting, and common explanatory languages can be used for scripting, such as Perl, TCL, Python, PHP, and Ruby. Perl is the oldest scripting language, and Pyth

Shell scripting 30 minutes to get started

the industry as a shell script, but reader friends know that Shell and shell script are two different concepts. For the sake of simplicity, the "shell programming" that appears in this article refers to Shell scripting, not the d

Shell combines expect to write bulk SCP scripting tools _linux Shell

When deploying a task, one of the necessary procedures is to send some files, such as installation packages, to a large number of servers. Although there is already a Brother Woo script available: A Python script written by the SSH and SCP features provided by the Paramiko module. But I'm still in the fear of Python (though I've worked hard in my spare time), so I've written this batch SCP scripting tool using a combination of

Collection of 48 shell scripting tips _linux Shell

This article collects a bunch of shell scripting tricks, I said, I write a blog mainly to make some learning notes to facilitate their own review, so I will make such an article, there is nothing incomprehensible. About the origin of these techniques, eh, I also forget, may come from Theunixschool, Commandlinefu, cool and igigo.net, of course, there are some of my own experience, tube him, into my brain is

Next-generation Shell scripting language, Windows power shell!_it Industry

folders, and ended up with a single command line: xcopy /e C:\Windows\assembly\GAC_MSIL G:\GAC_MSIL Then look for the desired assembly in the copied directory. Ha, now we can look at the PS code, it will be a very enjoyable thing.In addition, I found an additional assembly "System.Management.Automation.dll" through the _sfx_manifest_ file and the Reflector Analysis assembly reference, and its EXE note is "Microsoft Command-Line Shell

Shell script (i) Shell scripting basics using shell variables

The role of the shell: between the system kernel and the user, is responsible for interpreting the command line. · Shell programs that are used by default after logging in, typically/bin/bash Different shell internal instructions, operating environment, etc. will differ [Email protected] ~]# Cat/etc/shells /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash

Total Pages: 15 1 .... 3 4 5 6 7 .... 15 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.