Sync Post: http://blog.hacktons.cn/2017/12/13/shell-func-return/BackgroundWith Shell programming, custom functions are often required to write some tools for batch processing. In the case of more complex points, it may be necessary to return a value.
$ () and ' (anti-quote)In the bash shell, $ () and "(anti-quote) are used for command substitution.$ echo the last Sunday was $ (date-d "last Sunday" +%y-%m-%d)Get the date of the previous SundayThe reason for using $ ()
' (anti-quotes) is
1. The idea before writing a scriptConsiderUnified Script ManagementPermissions: User execution permissionsEmpty the error fileError hintsScripting Versatility2.2 Unified Script Directory1 mkdir /server/scripts2 cd/server/scripts2.3 Creating a
The role of the shell is to parse the user's instructions and combine the shell instructions with a specific process to form a script.To view the current system Shell version:Once you have written a simple shell script, there are several ways to do
The path is not shown in the Linux shell, and it is inconvenient to use it as a-bash-4.1#.How do I change the shell to show the path?The steps are as follows:Vim ~/.bash_profile(No tube. Bash_profile This file has a few, you can create a new one is
I. Rights Management1. View file propertiesLs-l2. Permission TypeIi. Linux Users and permissions1. User Management① Viewing usersID User1② adding usersUseradd user1③ Deleting a userUserdel-r user11. User Group① New GroupGroupadd G1② Deleting a
Shell Concept :The shell is a command-line interpreter that provides users with an interface system-level program that sends a request to the Linux kernel to run the program, and the user can start with the shell, suspend, stop, or even write some
1 Specifications for Shell scripts:1 file suffix is. sh2 first line is the command interpreter: #!/bin/bash3 The first line below the comment write script basic information:Script name, function, writing time, author, contact, etc.2 Shell Execution
Ubuntu Desktop window into the Shell window: Ctrl + ALT + F2~f6; Exit Shell window: Ctrl + ALT + F7; Enter UI Command window from UI, Ctrl + Alt +t
Shell Instruction Basic Format
-command name [options] -For example: detailed listing of all
In this article we learned how to use and define variables. According to the urine sex, the general next is to learn the basic data types of operations.Yes, this is still a cliché to talk about this boring but must learn basic data types of
In this article we learned about the use of conditional selection statements in the shell. The next step is to learn the looping statements. In the shell, loops are implemented through the for, while, until commands. Let's take a look at each one
(a) write the series as shown below[Email protected] ding1]# bash 5.sh2/13/25/38/513/821/1334/2155/3489/55144/89233/144The shell code is as follows:#!/bin/bash>aa>bbEcho 1 2 | Xargs-n1 >AAFor i in ' seq 20 'DoA= ' Cat AA | Sed-n ' $i ' P 'b= ' Cat
"Must be finished this time" series? Section--linux SHELL script Raiders. (Manual cover face ...) )1, the simple start. -"The only way to learn a new programming language is to use it to program"Don't think too much, just tap the code:[Email
CCat Zdd Browse the contents of a ZDD fileCat Zdd1 Zdd2 Browsing the contents of multiple filesCat-n ZDD Browse the contents of a file Zdd and display line numbersCD back to the start directory, that is, just logged into the system directory, CD
1.if statements(1) If statement of two-way branch(2) If statement of the multi-path conditional Judgment Branch2. Test statements(1) file test(2) String test(3) Numerical test(4) Test statements combined with logical operators3.case statements4.for
1. Generate a random password (urandom version)#!/bin/bash#author: Tintin (Jacob) #/dev/urandom file is a Linux built-in random device file #cat/dev/urandom can look inside the content, CTRL + C exit View # After viewing the contents of the file,
#!/bin/bash# Simple script for two number operations A+ -, altogether three parametersEcho$# #对获取的参数以此判断是否包含 [a-za-Z] Something, if included, to exit. Because numbers add up, not numbers, or subtraction. forI_argsinch "[email protected]" Do
awk commandawk ' Condition 1 (Action 1) Condition 2 (Action 2) ... ' FilenameCondition (pattern)General use of relational expressions as criteriaX>10 to determine if X is greater than 10x>=10 greater than or equal toxActions (Action)-Formatted
( a ) first look at how the Shell script executes, theShell script suffix is the sh file.1 sh test.sh2 Source test.shWhat is the difference between these two ways? The script in test.sh is simple , assigning a name variable after typing it from 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