Reprint please indicate source http://blog.csdn.net/imred/article/details/40951125
Under Linux to see some txt files often appear some garbled problem, so I wrote a shell script to GB2312 code into UTF-8 code
#!/bin/bash
#格式:./gb2312_2_utf8.sh
A problem encountered earlier is that the log file is too large to occupy the disk space and cause the build project to fail
So I wanted to write a timed task. Delete a log or compress a log file
I've been on the internet for a long time and haven't
Turn from: http://blog.csdn.net/edei2004/article/details/3694021
Many people think that telnet, like passwd and Su, cannot be turned on by pipes and inputs to make it work automatically, but Telnet actually supports input steering. Although,
Read two files at the same time, and merge their peers into one line to write to a merged file
Shell script:
#!/bin/bash
#set
-x CD ' dirname ' $ '/. /
inas_script_root= ' pwd '
function Make_if_no_existis_dir ()
{local
dir=$1
if [!-e ' $
Here are two ways to use the shell's regular expressions. use method One:
#赋值给变量var
read var
#定义regex正则表达式
regex= "[0-9]"
if [$var =~ $regex]];then
#match
#do Something
fi
For example, to match the input, the requirement must be a number
Recently looking for a job, do a pen test to sort algorithm, revisit Hill sort, the first time in the look of the times did not understand ... ⊙﹏⊙ b Khan So put yourself in the first time when the code encountered problems to be sorted out, in order
Specify the script interpreter
#!/bin/bash
Note: 1, the declaration can only be placed in the first line of the script, indicating that the script uses the Bash interpreter to interpret execution, otherwise it will be interpreted as Comment 2,
In a production environment, there is usually a large number of resident processes in a cluster, and it is necessary to be able to monitor and recover quickly when a process hangs.
The general Operation Engineer will choose to implement in Python,
Call volatility in the shell script, the volatility call is normal when the local test, but when the CGI program calls the shell script, there is no result output ... Why
There may be two reasons for the analysis: (1) Permission issues (2) Python
If statementSyntax 1
If condition
then command (set)
fi
The condition here is to use the test statement or the bracketed statement (the previous article has been summed up)Note If statement must terminate with FI
Practice:
#if test
if ["-lt"] # "13
Background information:
The project has two log folders, one for Tomcat itself, and two for the project.
This script is used in conjunction with Crontab once a week and can be done without restarting the Tomcat catalina.out normal situation to
Linux for loops can use break and continue keywords to jump out of loops, consistent with Java usage
a common for loop structure
#语法一 for
variable in value 1 value 2 value 3.
Do
program block done
# #语法二 The for
variable ' command '
do
Some special symbols.
$# the number of arguments passed to the script$* displays all parameters passed to the script in a single string. Unlike positional variables, this option argument can exceed 9$$ the current process ID number of the script
Recently looking at the script inside the OpenWrt, with too handsome, the following 2 parameters extended expression of large use, all recorded.
${parameter:+expression}
If parameter has a value and is not empty, use the value of
The set command sets the parameter variables for the shell. The output of many commands is a space-delimited value, and using set is very effective if you want to use one of these data fields.
#!/bin/shecho the date is $ (date)Set $ (date)echo 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.