System: CentOS 6.x
1. Install expect first
The code is as follows
Copy Code
Yum-y Install expect
2. Script content:
The code is as follows
Copy Code
Cat
Using the shell to combine awk is a good way to tell if a process is running or if a program file is being executed, as an example of PHP.
Define a crontab, execute every minute, the time interval is one minute, possibly next time executes, the
Method start
Check out the current shell
The code is as follows
Copy Code
[Phpbird@host3 ~]$ Echo $SHELL/usr/local/bin/bash
Of course, this is modified.Modify the default shell to modify the/etc/passwd
My colleague sent a shell question to find the maximum and minimum values in a multidimensional array.such as file 99file:33 55 23 56 99234 234 545 6546 3411 43 534 33 7543 34 76 756 33343 890 77 667 55
One of my implementations:
#!
The shell may often see: >/dev/null 2>&1
The result of the command can be defined as the output in the form of%>
/dev/null represents empty device files
> represents where to redirect, for example: echo "123" >/home/123.txt
1 indicates stdout
4.1 Sort Text
Sort of 4.1.1 RowsWhen command-line options are not provided, the entire record is sorted according to the order defined by the current locale.In the traditional C locale, which is the ASCII order.
4.1.2 Sorted by FieldThe-K option
The shell script reads data in several ways:1. keyboard input, default2. read from the file3. Pass through Pipeline command
Functions of Echo:\c: No Line change\f: Paper Feed\ t: the jump Grid\ n: Wrapping Line\ represents escape, for example:
The bash shell supports only one-dimensional arrays, but there are no restrictions on the number of arguments.Declare an array:Declare-a Array(In fact, you don't have to declare that you can assign a value directly to a variable in an array, and
I said, the shell is my conventional weapons, although not yet proficient, but I love the shell of the language, under Linux mixed, always write a script. Programmers have genes, there is a preference for programming languages, you let me write C
The awk function split (S,A,SEP) splits a string s into a awk array a using the delimiter Sep.
Set time = 12:34:56Set hr = ' echo $time | awk ' {split ($0,a, ":"); Print a[1]} ' # = 12Set sec = ' echo $time | awk ' {split ($0,a, ":"); Print A[3]} '
I do not know if you have the same shoes have no management of hundreds of Linux operating system experience, although through SSH private key can be password-free landing, but every day input dozens of times the server IP address, I really like to
A simple shell script to find out if a critical service is running and is suitable for Linux or UNIX operating systems.The script can also send notifications using e-mail.
Code:
Copy Code code as follows:
#!/bin/bash
#
Xargs is a filter that passes parameters to a command and is a tool for combining multiple commands. It divides a data stream into small enough chunks to facilitate the processing of filters and commands. Typically, Xargs reads data from pipes or
Shuffle problem: Wash a pair of poker, what good way? Can be washed evenly, and can wash quickly? What is the efficient implementation of a disorderly arrangement relative to a file?
Chinaunix is indeed the place where the Shell masters are
Recently managed a number of machines, there is a need to unify the change of an account username password, such as the QA account password changed to 1234, and later for scripting, very convenient implementation, but also used to modify the user's
It is not a programmer's job to tailor an icon of every size needed to the shelves one at a time before the app is put on the shelves, and using the SIPs tool from the MAC can solve this requirement.With respect to SIPs, the following information
1. Background
When multiple processes may perform operations on the same data, these processes need to ensure that the other processes are not operating to prevent damage to the data. Typically, such a process uses a "lock file", which means that
ECHO is an internal instruction of the shell to print out the specified string on the screen. Command format:
Copy Code code as follows:
Echo Arg
You can use echo to achieve more complex output format control.
Show escape
Shell Basics 20 Articles Editor's note: The Shell Foundation 12 and L_kernel supplemented by Wingger's 13th-20 articles, covering all aspects of Shell programming and use, with a large number of examples, perfect for beginners system learning. What
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