This article mainly introduced 8 practical shell script sharing, this article has given the judgment input number character, the character or other, asks the average, the self decrement output, adds the prefix in the file, the batch test file
This article mainly introduces the shell script to empty more than 1G log files, this article directly gives the implementation code, the need for friends can refer to the following
A question about how to automatically delete a specified file
This article describes a shell script for uppercase and lowercase conversions, learning the use of commands such as TR, awk, and sed. Have a friend in need of reference under
The following script allows you to convert directories or file uppercase
1 if statement
echo "Please input X"
Read X
echo "Please input Y"
Read Y
If [$x-gt $y]; In the [] condition, there must be a space before the [only space is followed]. Only a semicolon can be available, or there can be no semicolon
Then
echo "
1, teach you to reduce the external appearance of the notebook wear
A good notebook how to maintain their own shell, must be a good packaging, and notebook is the same, you need a good quality notebook outsourcing and a soft notebook bag to protect
In bash, Bash's math is a little awkward, it's hard to adapt and remember, so you have to write a blog post to make it easier to look through. There are four ways to perform mathematical operations:
A, let order
Copy Code code as follows:
1. Take today's time
Copy Code code as follows:
$date-D "Now" +%y-%m-%d
2. Take yesterday time
Copy Code code as follows:
$date-D "Yesterday" +%y-%m-%d
$date-D "1 days ago" +%y-%m-%d
# # D,--date=string
Unlike Java, PHP and other languages, the process control of SH is not NULL, such as:
Copy Code code as follows:
if (Isset ($_get["Q"])) {
Search (q);
}
else {
Doing nothing
}
?>
You can't write this in Sh/bash,
A period of time before a batch to modify the file name, is a Debian file server, for the Mac to provide file sharing services, the Chinese part of the Use of encoding (check the data, should be, not to actually verify), the specific coding
logical operators
logical operators used in [] and test
logical operators used in [[]]
Description
-A
&&
And and, both ends are true, then true
-O
||
Or OR, at both ends
The terminal realizes the reading and writing of the data stream in the file;The list of REDIRECT commands is as follows:
Command
Description
Command > File
Redirects the output to file. Write terminal data
Like many of my classmates, I was confused shell programming before I learned shell programming, but I didn't know what it could do, but I felt I could use a different way to manage the system. Now I slowly understand the importance of the shell for
Exercise: Write a scriptDetermine if there is a user's default shell for bash on the current system;If so, the number of such users is displayed, otherwise, no such user is shown;#!/bin/bash#grep '\'/etc/passwd&>/dev/NULLRETVAL=$?if[$RETVAL-eq0];
You can often see them in a scheduled task. Examples of our company's planning tasks include:*/2 * * * * * root cd/opt/xxxx/test_s1/html/xxxx/admin; PHP index.php task Testone >/dev/null2>&1*/2 * * * * Root cd/opt/xxxx/test _s1/html/xxxx/admin; PHP
Tag: One put BSP compresses rect permissions. GZ mnt gzip8th: Shell script Archiving and compressionRegular backups are not trivial, and we can automate backup through shell scripting. Where data backup is generally used to archive and compression,
The shell variable $# in Linux,[email protected], the meaning of $0,$1,$2 is explainedExcerpt from: Abs_guide
The meaning of shell variable $#,[email protected],$0,$1,$2 in Linux is explained:Variable Description:$$The PID of the
#!/bin/bash ## description: the script function, cycle in weeks; Friday full backup, Saturday No backup, Sunday to Thursday differential backup;# due to work needs, do not implement compression packaging method, using CP full backup,
Shell scripts to bulk operate Linux hosts:I. Introduction to the Environment:Turn on 192.168.100.150-152 (ctos1-3) and 192.168.100.100 (VSFTPD).1.SSH Login: Operate on 192.168.100.1001) Password login 192.168.100.150:SSH [email protected] #
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.