Alibabacloud.com offers a wide variety of articles about linux shell scripting tutorial for beginners, easily find your linux shell scripting tutorial for beginners information here online.
This article is part of the Linux Shell Series Tutorial series, which includes the following 18 parts:
Linux Shell Series Tutorial (a) Shell introduction
No orders found.
128
Invalid exit parameter
128+x
Critical error for Linux signal x
130
Command terminated with CTRL + C
255
Exit status code out of bounds
Exit Exit command can specify exit status code, but not more than 255, otherwise it will be moduloCode 1-16[Email protected]:/data# cat Demo4 #!/bin/bashdateecho $?whoexit 5[email protected]:/data#./dem
-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
/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
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
, 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
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
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
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
value of a running process Renice-n PIDNohup SH executes scripts in the backgroundCtrl Z hangs a foreground processFG Job Number The file foreground runs the BG job number to run the file background/proc DirectoryShell Scripts Scripta shell script is a text file that contains a shell directiveShell and oh ah this supports variables with simple syntax to complete batch workHow
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
First, Shell introduction
The design of many Unix-like operating systems is stunning. Even today, the UNIX-style operating system architecture remains one of the best designs ever. One of the most important features of this architecture is the command line interface or shell. The shell environment allows users to interact with the core functions of the operating
1, the beginning
The program must start with the following line (must be on the first line of the file):
#!/bin/sh
The symbolic #! is used to tell the system that the parameters behind it are the programs used to execute the file. In this example we use/BIN/SH to execute the program.
When you edit a good script, you must also make it executable if you want to execute the script.
To make the script executable:
Compile chmod +x filename so you can use it. /filename to run
2, Notes
In
packing and decompression, but the two processes are separate, and in general, the two processes are not separate, but instead they are packaged into a single compressed package in a single step with the TAR package. The following three compression methods are called using the TAR command respectively to complete a step to package multiple files into a single compressed package. 1. Invoke gzip with tar to generate a compressed package File1,file2,file3 TAR-CZVF file.tar.gz file{1,2,3} 2. Call b
recommend Ruby. Ruby, you can refer to the book I wrote: Chef-GitBook
There are currently three common O M languages: Shell Scripts, Perl, and Python. Let alone shell (no matter which one you choose last, shell won't be able to get around, even if you are not proficient at least, you should be proficient ). In Perl and Python, the current choice is of course th
This article is part of the Linux Shell Series tutorial (17), more Linux shell tutorials: Linux Shell Tutorials
Through file inclusion, you can reference the contents of other files,
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.