1, the simplest way
Copy Code code as follows:
: .... Comment Content
Block
The input is redefined to the previous command, but: it is an empty command, so it is equivalent to a comment.If a command with an inverted
In the process of doing keyword cleaning, you need to filter out a class of words that do not conform to the end of a word, the idea is to put this batch of words according to the last word sort, so think of the first of these words to reverse, such
Shell Batch collection Love Station keyword library, the whim of the play, not perfect, first put out, later slowly update, although the function is simple, similar tools are also many ready-made, but after all, it is their own writing tools,
Sometimes when we process and view files, there are often a lot of empty lines, in order to be beautiful or need, it is necessary to remove these lines, the following methods:
1) with the TR command
Copy Code code as follows:
Cat
Speaking of function calls, I believe that we will not be unfamiliar, however, for beginners shell of me, the shell function call Way is a little let me not too accustomed to, I have gone a lot of detours, because the transfer parameters when a very
1. List all directory usage and sort by size.
Copy Code code as follows:
Ls|xargs Du-h|sort-rn
#不递归下级目录使用du-sh
2. View the file exclusion with the # switch and blank line, suitable for viewing the configuration file.
Copy
First, the script idea
The first step is to rename the log file without having to worry about renaming the log file and losing the log when Nginx is not found. Before you reopen the log file for the original name, Nginx still writes to the file you
Copy Code code as follows:
#!/bin/bash
Path=/bin:/sbin:/usr/bin:/usr/sbin
Export PATH
I=1
While [$i-lt] #硬盘数量, 12 blocks apart from the system disk
Todo
J= ' echo $i |awk ' {printf '%c ', 97+ $i} ' #系统盘是sda, if the other needs to modify
Linux how to count the current directory under the number of files, and how many directories?
Write a script with the shell below, put it in the current directory, and execute it.
Copy Code code as follows:
#!/bin/bash
#脚本名称
Always want to write expect action in the Bash script, so I do not have to write two scripts to execute, and made a little achievement in the afternoon finally, to show you.
System: CentOS 5.x
1. Install expect first
Copy Code code as
Write a script to check whether the Apache process exists, if it does not exist, the display does not exist, if it exists, display the number of processes, when not equal to 10, notify the administrator in red font, and ask the administrator whether
But add the user, this one shell.users is enough. This may also be a new method of adding a user, possibly with the deletion of Net.exe and no ADSI. The code is as follows:
Js:
Copy Code code as follows:
var o=new activexobject
1) Statistics the number of files under the current folder
Copy Code code as follows:
Ls-l |grep "^-" |wc-l
2) Statistics the number of directories under the current folder
Copy Code code as follows:
Ls-l |grep
This blog is simple to look at the loop statements that Shell programming uses, including for loops, while loops, until loops, for behind and a variable, and then a collection that assigns things to this variable, each loop, like a foreach in Java.
A sensitive user here means that the user belongs to more than one group, or that the user belongs to a group name that is not the same as the user name.
#! /bin/bash
#list user who belong than one group
#and list user who belong to the
The shell supports custom variables.
Defining variables
When you define a variable, the variable name is not a dollar sign ($), such as:
Copy Code code as follows:
Variablename= "Value"
Note that there can be no space
The Web server uses memcached, but does not know why memcached always hangs (basic 20 minutes ~ 50 minutes), causes some website page to visit the time error; When you define the log, you cannot see what ; Preliminary determination is related to the
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