&&Command 1 && Command 2: If this command executes successfully && then execute this command.[Jb]/usr/xxxx/ytcclb>ls-l Test.sql-rwxr--r--1 xxxx Group Nov 14:12 Test.sql[JB]/USR/XXXX/YTCCLB>CP test.sql Test.bak && echo "Coping file ok!"Coping file ok!
Back up Web site content
Copy Code code as follows:
#!/bin/bash
#指定运行的脚本shell
#运行脚本要给用户执行权限
Bakdir=/backup
Month= ' Date +%m '
day= ' Date +%d '
Year= ' Date +%y '
Hour= ' Date +%k '
min= ' Date +%m '
Dirname=
Implementation: SSH remote login, each time to specify a bunch of user names and passwords, is required to implement automatic login.Login process: Local A first log in to B and then log on to the final C
As follows:
Copy Code code as follows:
Shift can be used to move position parameters to the left.Shell's name is $The first argument is $Second argument $Nth parameter $nAll parameters $@ or $*Number of parameters $#
Shift default is shift 1Take the example below:
Copy Code code
The following script allows you to convert directories or file uppercase and lowercase letters as follows:
Copy Code code as follows:
#!/bin/sh
#edit by Www.jb51.net
# [: Upper:] [A-z]
# [: Lower:] [A-z]
# [:d igit:] [0-9]
If, for, while almost all the keywords in all programming languages, in Shell programming is no exception, where if is the most frequently used, because shell programming does not exist in the concept of objects (object), so in the comparison of the
The first idea, with iptables the external network SSH packet drop off;The second idea, with Tcpwrapper to sshd allow write death;The third idea, revise sshd_config, only listens intranet request.
Due to some unclear reasons, the iptables approach
If you're dealing with a shell script and it's a common thing to traverse a time range, share it with you today:
Copy Code code as follows:
#!/usr/bin/env Bash
Date1= "$"
Date2= "$"
echo "Date1: $date 1"echo "Date2: $date 2"
Recently read an article through Nagios to realize MD5 real-time monitoring iptables status, I would like to see if the shell can also do monitoring iptables rule changes, after the experiment, there is the following script.
System: CentOS 5.x
Copy Code code as follows:
#!/bin/bash
#Description: Delete Files
#===== defines the current year, the month, and the directory where the file resides =====#
Currentyear= ' Date +%y '
Currentmonth= ' date +%m |awk-f ' 0 ' {print $} '
Copy Code code as follows:
useradd.sh
#!/bin/bashFor name in Tom Joy John Mark JamesDo Useradd $nameecho "Redhat" | passwd--stdin $nameDone
OK, after the execution, the new user will be automatically created Tom, Joy, John, Mark, James,
For example, I have 100 executable files, there is no special relationship between each other, such as code:
Copy Code code as follows:
Job_1
Job_2
Job_2
.....
job_100
Want to use Csh/bash to multithreading call
The security and stability of the server is the goal that every operational dimension wants to achieve, after all, once the site traffic is big, visit high, there will be some boring people to attack, to help detect the loophole is good, but the
We have such a string:
Copy Code code as follows:
info= ' ABCD;EFGH '
Now to get ABCD and efgh, we can simply use the cut tool to get:
Copy Code code as follows:
Fstr= ' echo $info | cut-d \; -F 1 '
Sstr= ' echo $info |
The core server ran a bunch of scripts, procedures, it is inevitable that sometimes zombie process, dead or alive in the occupied resources there, initially just wrote a keyword to kill the process of the Linux shell script, and later found that
You need to find the last position of one of the characters in the string, which is available in PHP (Strrpos) or Perl (Rindex), and you can't think of a way out of the shell. Post on the Forum also no one answer (do not know whether the problem is
This script was modified on the Zhang Yi cache cleanup Script, the main is to add the IF option and optionally list the address of the cache file based on the parameter type (because it is not fixed, sometimes a particular JPG type, sometimes a
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