14.2 reading user input
14.2.1 Variable
In the previous chapter we talked about how to define or cancel variables, which can be set to the current shell's local variables, or environment variables. If your shell script does not need to invoke other
When I was developing Android, I encountered a service component that simply would not require the interface behind the process to silently perform the task. Now let's learn how the daemon service is implemented under Linux, and also learn the
The loop structure under the Shell is Class C, also has a for loop, while loop, in addition, the shell also has a until loop. For Loop the basic syntax for a for loop
For variable in {list}
do
statement1
statement2
... Done
The syntax
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
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
Today, there is a problem that needs to be judged whether there is a. c file in the directory. I used the IF [-f *.c], using the-F and wildcard characters to determine if there is a. c file, while Linux always complains "unexpected operator", so
The time display command under Data Command Linux, not the Times command, which is the timing command for the commands:
Man date ...%m Month (01..12)%m minute (00..59)%n a newline%N nanoseconds (000000000..999999999)%p locale ' s equivalent of
1, Documents:
1.1, the file access to 3 kinds of ways:
1 read (show file contents), 2 write (edit, delete, modify permission), 3 execute (Run shell script, program, etc. executable files).
1.2, the file can be divided into 3 kinds of permissions:
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, #. /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:
forwarding https://my.oschina.net/weiqingbin/blog/190929
You can set the following options when you start Impala-shell to modify the command execution environment. Note:
These options are different from the configuration options for the Impalad
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
1. Use shell script to find the process ID corresponding to the program and kill the process
#!/bin/sh
name=$1
echo $NAME
id= ' ps-ef | grep "$NAME" | grep-v "grep" | awk ' {print $} '
echo $ID
E Cho "---------------" for
ID in $ID
does
kill-9
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 echo CommandThe echo command of the Shell is similar to the echo command of PHP, and is used for the output of strings. Command format:echo stringYou can use echo to achieve more complex output format control.1. Display normal string:echo "It
If statement1, according to the file type to judge-d file) to determine if the file exists and is a character device file (the character device is true)-e file) to determine if the file exists (exists as true)[-e/root]echo $? The output is 0 #判断为真,
1. Functions in the shellThe function is to organize a piece of code into a small unit, and give the small unit a name, when the code is used to call thisThe name of a small unit.Format: function F_name () {Commond}function must be placed at 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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service