Simple shell scripts for tasks without variables are generally competent. However, when executing some decision-making tasks, it is necessary to include the IF/then condition judgment. Shell script programming supports such operations, including
If you have multiple NICs, you must specify the NIC name because the IP address is related to the NIC.
The method for getting the IP address of the specified Nic is:
Ifconfig eth0 | sed-n "p" | awk '{print substr ($ )}'
"Eth0" indicates the
Linux running levelAfter Linux is started, it runs at one level. The following lists the running levels:0 system stopped1 single user system, no login required2 multi-user system, but does not support NFS, command line mode Login3 full multi-user
Merge and split files:1. SortCommand Format:Sort-CMU-O output_file [other options] + pos1 + pos2 input_file-C: whether the test file has been classified.-M combines two classification files.-U: delete all duplicate rows.-O stores the output file
For Dev and UAT environments, databases must be in archive mode, but do not need to be backed up. Therefore, the constant increase in archive archiving logs results in a large amount of disk space consumption. In this case, you can use a shell
#! /Bin/shFiles = ""Trcase = ""EXT = ""Opt = No
# Gets called when a conversion failsError_msg (){_ Filename = $1Echo "'basename $ 0': Error The Conversion failed on $ _ filename"}
If [$ #-EQ 0]ThenEcho "for more info try 'basename $ 0' -- help"Exit
F statement format
If conditionThenCommandElseCommandFi, don't forget the end.
If statements forget the final fiTest. sh: line 14: syntax error: unexpected end of fi
Three conditional expressions of if
root@bt:~/test# chown --helpUsage: chown [OPTION]... [OWNER][:[GROUP]] FILE... or: chown [OPTION]... --reference=RFILE FILE...Change the owner and/or group of each FILE to OWNER and/or GROUP.With --reference, change the owner and group of each
Linux shell scripts that safely kill Tomcat processes, as many good script programming skills are used in this script, I would like to share with you;
## Firstly find the process of the tomcat ....Tomcat_process_str = 'ps aux | grep 'java. * Tomcat '
UsedIf/whileAnd so on;
Test
Command
Test Condition, When the condition isTrueReturns0;
IfTest condition; thenIf[Condition]; then#Note the space,TBDSupported?If 0
......
FiFi
Test
Condition judgment, three types
1) Value
Find out the difference between for and while, and write out the memo.
Script:
File =/home/hadoop/phrases.txt for content in 'cat $ {file} 'Do phrase = 'echo $ {content}' echo $ phrasedone
The phrases.txt file contains the following content:
Shell script Learning (III): Shell functions and some common symbols and commands
I. Shell functions
Like C, Shell functions encapsulate commands and statements that have fixed functions and are usually used repeatedly in a single function, if you
Linux mobile phone DIY. Shell application extension 1. Random incoming ringtone (e680 Series)
Papayas
2007-03-18
I. What is shell?
Before getting started, I always used to copy some stuff from the Internet to "enrich" the content of the
By using the runtime.exe cute method, we can run the Linux Shell script in a Java program or execute other programs. Referring to this article on the Internet: http://lee79.javaeye.com/blog/418549 (thanks), I rearranged the code.The
[Cracked by] layper[Author mailbox] layper2002@yahoo.com.cn[Author's homepage] www.sy135.com[Tools] peid, OD,[Cracking platform] Win9x/NT/2000/XP[Software name] single-step Analysis of Shell and shell chaos (5)[Statement of cracking] I am a cainiao.
We have completed the first three steps. We will analyze the implementation of the entire shell script again:
Implementation Process Analysis:
1. Partition: Format and partition the selected disk.
2. Attach the disks in user-defined partitions to
Sometimes in bash shell, we need to obtain user input information, such as user name and password. The password cannot be displayed... In the face of such requirements, the practical command read can be implemented.
Read-P "input your Username:"
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