Original address: http://blog.chinaunix.net/u/21908/showart.php?id=1420565 reference
* Learn Bash Shell 3rd edition 6.4. Arrays
You can also use array variables in Bash, which are assigned two types of values:(1) name = (value1 ... valuen) at this
Question: For string output such as ' 1,2,3,4,5 ', separate 1 2 3 4 5
Feature: no spaces in string
Workaround 1:
#!/bin/bash
var= ' 1,2,3,4,5 '
var=${var//,/} #这里是将var中的, replace with space for
element in $var
do
echo $ Element done
Write:
The shell script is actually a plain text file (ASCII), and we can edit the file to help us execute multiple instructions at a time, or use some operational and logical judgments to help us achieve certain functions. The same considerations
1. String judgment
STR1 = str2 When two strings have the same content, the length is true
STR1!= str2 is true when strings str1 and str2 are unequal
-N str1 True when the length of the string is greater than 0 (string not empty)
-Z str1 True when
[Root@centos65 liumengyang]# cat test.sh
#!/bin/sh
#if The process Exists,kill it
pid=$ (Ps-ef|grep java| awk ' {print $} ')
pidname=$ (ps-ef|grep java|grep-v ' grep ' |awk ' {print} ')
#judge If the process is Running.if Not,restart.
If
The sort command sorts multiple rows of data in a behavior unit.For example, there is a text file Test_sort, which has five elements, using the sort command, the five elements can be sorted in dictionary order from small to large.If the sort command
Positional parameters can be moved left with the shift command. For example, shift 3 means that the original $ $ is now $, the original $ $, and so on, the original $ $, $ $, $ $ no move. The shift command with no parameters is equal to shift
Gzexe
Installation and use
The system is self-contained with no installation required.Use the following command to encrypt:
Gzexe tesh.sh
After the encryption is complete, test.sh is the encrypted file, while the source file is backed up as test.
After you understand the basic statements, you need to implement your own ideas. Start to do some judgment on the condition of learning.
Test
Test is an expression of a shell program that can be conveniently tested with strings, file states and
Often to deploy multiple servers above the application, if a machine's login too cumbersome.
All just think about writing a script to deploy different servers
Prerequisites:
Configuring SSH Login Free
If not, please join me in another article http://
First, there is only one type of string in the shell, no shaping or floating-point type.
However, when you define a variable, you can use single quotes, double quotes, and no quotes. Without quotes, if the variable has a white character inside it,
Recently started to learn bash shell, I do not know where to start, do not know what a good tool package to learn it. First Look for:
yao@wuyao:~$ Apt-cache Search BashApparix-console-based Bookmark Tool for fast file system navigationBackup-manager-
First, the user login into the system after the system environment variables:
$HOME user's own directory
$PATH directory to search for when executing commands
$TZ Time Zone
$MAILCHECK every few seconds to check for new letters
$PS 1 The prompt
An application system every day to insert data to the database, and for very early data need to be cleaned from the database, to prevent unlimited data increase, the cost of storage and impact data query efficiency.
Implemented through two files,
The 1.expr command is generally used for integer values in the general format:
Expr argument operator argument
The general usage is to do arithmetic operations using expr, such as:
[Root@centos ~]# expr 10 + 20
30
$expr 30/3/2
5
(Note that operators
Shell to bulk modify file name under folder:
Parameters: Incoming file path, such as:
$./batch_rename_files.bat /home/xx/channel/
#!/bin/bash
echo "Start programming ..."
# #for i in ' ls * ' CD $
# #for i in ' ls-r | grep "erl*" '
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.