Judgment file:Workdir=/home/tmplocal_list_file= $WORKDIR/local.list#if no Local.txt file, generate a new oneif [!-F "$LOCAL _list_file"]; ThenTouch $LOCAL _list_fileFiNote: Be sure to have a space, to determine whether the file exists, if it does
Linux Shell string interception is useful, there are eight ways:
Assuming there are variable var=http://www.aaa.com/123.htm
1. # Intercept, delete left character, keep right character.
Echo ${var#*//}
where Var is the variable name, # is the
Because of the need to use the shell to develop a number of gadgets, when using an array as a function parameter, found that only the first element of the array can be passed, the elements behind the array can not be passed into the function.
In recent time, when dealing with shell scripts, encountered time processing problems. The addition and subtraction of time, as well as the calculation of timing.
1. Time plus minus
The way to do this is to turn the base time into a timestamp,
The Java Execution Shell command has not been used before, and it is thought to be as convenient as C, and can be done with a system function. It's not that much of a problem today. There are two ways of executing shell commands in Java:
1. Use of
Often when writing a shell script, you will encounter a different user to execute the relevant commands, the way to simply note:
1. Execute a single command: su-user-c "command"
For example, the following command is to create a test123 directory
Source: This article originates from: http://sinbad.zhoubin.com Author: Unknown (2002-12-12-06:02:00)
Simple and easy to find, and learn it as a socket programming example. /**/ /*======================================================================
The variables are divided into three types:1, ordinary variableis the local variable. Variable is the variable name
Variable=value//= the left and right sides can not have spaces, otherwise it will be treated as commands, output a command not
Http://www.cnblogs.com/davidwang456/p/3784102.html
http://blog.csdn.net/yucan1001/article/details/8455757
http://blog.163.com/yangfan876@126/blog/static/806124562013720104712282/
1, dirs1) functionDisplays all records in the current directory
There are two ways to let echo output a color
1. Define the color variable in the shell script and use ECHO-E to invoke the variable
2. When defining variables, define the ECHO-E into a variable, and then output the variable
Shell script that allows
Recently learning a Linux script, here is the meaning of $, $, $!, etc. in shell scripts
Variable Description $$The PID of the shell itself (ProcessID)$!PID of the Shell's last running background process$?End code of the last Run command (return
Http://www.cnblogs.com/wangkangluo1/archive/2011/09/23/2185938.html
Name: PSUsage rights: All usersHow to use: PS [options] [--help]Description: Shows the dynamics of the instantaneous stroke (process)Parameters: The parameters of PS are very many,
Because of the job needs, because to determine whether rsync is successful, at first I was to judge the local file there is no to that do quiteSafety, now to push the data past, I can not judge, only with the rsyncreturnIn the first place, the '
PrefaceThere is a problem with working today, if you copy the file in directory A to directory B (without the file in directory B), and keep the file structure in directory A. The project focuses on the following: You need to keep the structure of
Recently work required, wrote some shell scripts to do server one-click Package Update,
Traversing a folder with a for recursion contains spaces in the file name, which is treated as two files
Workaround: Modify the delimited IFS
#! /bin/bash
Gets the names of all the folders under the specified directory/usr/and outputs:
Shell code:
1 #!/bin/bash
2 #方法一
3 dir=$ (ls-l/usr/|awk '/^d/{print $NF} ')
4 for I in $dir
5 do
6 echo $i
7 done
8 #######
9 #方法二
-dir in $ (ls/usr/)
#!/bin/bash
db_ip=
Db_user=
Db_passwd=
Db_name=
a=98000000
function Addsql ()
{
Ine2=$1
Ine3=$2
#sql1 = "Update table name set list = ${ine2} where id= ${ine3};";
sql1= "Update table name set sex=0 where id= ${ine3};";
echo $sql 1
Mysql-u $DB
Some time ago in the study shell script, the last mention of the SED mode space and maintain the concept of space, but has not studied well, these two days studied, so it sent, not very comprehensive, just for your reference.
Keep the space sed
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.