There are several main ways to do this:
echo "$str" |awk ' {print length ($)} 'Expr Length "$str"echo "$str" |wc-cBut the third one will be 1 more, maybe the terminator is counted.There are three ways to determine that a string is empty:If ["$str" =
1. Install SSH, install Needless to say, always click Next
2. Click SSH Secure Shell Client and click on Quick connect above.
Host: IP address of the connected Linux (on Linux, log on as root, ifconfig view IP address as shown below)
)
User:
string Slices${#var}: Returns the length of the string variable var
[Root@centos6 ~]# alpha= ' echo {A. Z} |tr-d "" \ Create a variable to assign 26 letters to it, and no spaces
[Root@centos6 ~]# echo $alpha
abcdefghijklmnopqrstuvwxyz
[ ROOT@CENTOS6
The problem is:4) Known: The content of/etc/hosts is
192.168.1.11 oldboy11.etiantian.org
192.168.1.21 oldboy21.etiantian.org
192.168.1.31 oldboy31.etiantian.org
#192.168.1.111 oldboy111.etiantian.org
Please use the shell script to realize, how can
Shell script, if judgment statement error [: Too many arguments
I have encountered two situations:
1, the first situation is that the Internet, you can say, the string variable may exist in a space, shell resolution when it is considered to be more
Strictly speaking, there is no concept of an expression in the shell. The shell itself is simply a collection of commands, and certainly not a bunch of random piles, but a certain organization. But this organization is not so rigorous, so this
my first understanding of sed
Sed is an editor, a command-style text editor. SED can be executed as a command in a terminal, or it can be saved as a SED script text-an executable sed script file, and then execute the script file. The SED editor,
believe that the progress bar everyone is not unfamiliar, every time you download something or software will be prompted by the current download task to achieve how much, of course, can have different languages to achieve, today I use a shell script
1. Peanut Shell
The purpose of peanut shells is to apply for a free domain name.
The application method is very simple, is to download a peanut Shell client, register a peanut shell account, and then you will get a free domain name.
My account name
1. When defining a variable, no spaces can be left on either side of the = number.egGender=femal ———— RightGender =femal ——— –wronggender= femal ——— –wrong2. Conditional test statement [Both sides of the symbol must be left blank.egif [$gender =
~ Represents the current user's root directory/home/username/
/represents all the root directory
. Represents the current directory
Copy files:1. Copy Local files to remoteSCP filename User name @ computer IP: remote path2. Copy files back to local
A shell process is a process that executes other processes, but when a command is executed, the shell process instructs the kernel to execute the specified program separately as another process and write the output to the terminal. With the command
This paper mainly introduces the 4 methods of the shell reading files by line: While loop method, redirect method, pipeline method, file descriptor method.
method 1:while The most efficient and commonly used method in the loop.
The code is as
1, #. /bin/sh Opening
2. Variables:
(1) Definition: variable name = string. Note: = no spaces around; name= "Hello World" for which a string with spaces is assigned;
(2) Citation: Use $nametest, ${name}test.
3. Wildcard characters:
(1) * symbol:
1.6.2 Default shell environment variables and PATH variable settings
1. Default shell environment variables
Bashshell default will use some specific environment variables to define the system environment. You can always rely on the variables set
Options for UNIX types: UNIX has the advantage that standard UNIX commands have the same command-line format at execution time: command-options parameters if the shell is executed in the same format, the Bourne shell provides a A statement that
Function: Title
Code:
#!/bin/sh recursive () {for file in $ do subfile= ' ls $2$3/$file ' for SUBSUBF
Ile in $subfile do # echo $subsubfile if ["$subsubfile" = = "$2$3/$file"] Then RM-RF $3/$file mv $subsubfile $3/$file else
Shell commands, which can be split by semicolons, or by line breaks. If you want to write multiple commands in one line, you can pass the ";" Segmentation.
Such as:
bldr:deyuy/bin/my_shell>>a=5;if [[A-GT 4]]; then echo ' OK '; fi;
If statement
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