Using the return value of a function in a shell script

#!/bin/bash- function mytest () { echo "arg1 = $" If [$ = "1"]; then return 1 else return 0 fi}if MyTest 2; Then echo "Aaaaaaaaaa" fi Execution Result:Change it a little bit.#!/bin/bash-function mytest

Tips for Shell

Tips for ShellThere'll is some case-based tips for Shell.1. Replace The sequence space with newlineInput Examplea b c dOutput ExampleabcdSummarysedis the best solution.Solutionsed -r -e ‘s/[[:space:]]/\n/g‘2. Sort the unordered word list (with

Common shell commands

1. See if a program is running ps–ef|greptomcat 查看所有有关tomcat的进程 2. Terminating a thread kill-9 2222  3. View files, including hidden files ls-al 4.

Shell commands used in a development

1. Time CalculationStarttime= 'Date+'%y-%m-%d%h:%m:%s''; Endtime=`Date+'%y-%m-%d%h:%m:%s''; Start_seconds=$(Date--Date="$starttime"+%s); End_seconds=$(Date--Date="$endtime"+%s);EchoEnd_seconds-start_seconds2. Get the status code returned by the

Command substitution and eval commands under the shell

In the shell, if you want to get the return value of a command, if it is an integer, you can get its exit code directly with $.But if the return value of a command is not an integer, how is it implemented?Have to mention the command substitution

Shell and if-related parameters

[ -a FILE ] FILEtrue if it exists. [ -b FILE ] True if it FILE exists and is a block special file. [ -c FILE ] FILEtrue if a special file is present and is a word. [ -d FILE ] True if it

##*,%%* Problems in the shell

Suppose we define a variable as:File=/dir1/dir2/dir3/my.file.txtDifferent values can be replaced with ${}, respectively:${file#*/}: Remove the first one/And the string to its left:Dir1/dir2/dir3/my.file.txt${file##*/}: Erase the last one/And the

2.Linux Shell function

Order of 1.Shell Search commandsWhen the shell executes the command, it does not directly look in the path path, but instead looks for the command location in a fixed order. The search order is as follows.1. Aliases. Even if you create a command

Shell String Segmentation

Syntax 1:substring=${string:start:len}The subscript of string starts with 0, with start, but the Len character is truncated and assigned to substring1 #!/bin/bash2 #substr =${string: Start:len}3 str=" 123456789 " 4 substr=${str:3:3}5echo $substr6 7

1.Linux variables in the shell

1. Shell Variable TypeThe shell is a dynamic type language (not using explicit data declarations) and weakly typed languages (variable type operations vary according to requirements). The variables in the shell are non-typed (all string types), but

Initial knowledge of Shell environment variables (sixth chapter)

1. The concept of environmental variablesEnvironment variables are used to store shell sessions and work environments, allowing the shell to easily access the program in the set value, environment variables are divided into global variables and

Shell Command Basic knowledge point

Command history# Cat/root/.bash_history//place where historical commands are stored# History//View the number of command histories# echo $HISTSIZE//View the number of bars that can be saved# Vim/etc/profile//Change the value of variable histsize

Understanding the Shell (Chapter fifth)

1. Type of shell[Email protected] ~]# ls-l/bin/*sh-rwxr-xr-x. 1 root root 938832 Jul 2013/bin/bashlrwxrwxrwx. 1 root root 4 Oct 2014/bin/csh-tcsh-rwxr-xr-x. 1 root root 109672 Oct 2012/bin/dashlrwxrwxrwx. 1 root root 4 Oct 2014/bin/sh-bash-rwxr-xr-x.

Shell Special variables: $ A, $#, $*, $@, $?, $$, and command-line arguments

variable names can only contain numbers, letters, and underscores, because some variables that contain other characters have special meanings, and such variables are called special variables. List of special variables

Common shell Scripts

#!/bin/bash # Check if the 192.168.1.1-192.168.1.254 host is aliveFor IP in 192.168.1. {1..254};DoIf ping-c 1 $ip >/dev/null; Thenecho "$ip OK."Elseecho "$ip no!"FiDone#!/bin/bash #检查多个域名是否可以访问Url= "www.baidu.com www.sina.com www.jd.com"for URL in

Shell uses the Paste command to stitch multiple files by column

Test documents:[email protected] shell-script]# cat Text1.txt12345[email protected] shell-script]# cat Text2.txtOracleMysqlPostgreSQLHadoopSparkUsing Paste stitching text1.txt text2.txt file contents:# paste Text1.txt text2.txt1 Oracle2 MySQL3

"Shell Programming" 2, syntax

First, declaring variablesMyurl= "http://see.xidian.edu.cn/cpp/linux/"mynum=100Attention:There can be no spaces between the variable name and the equals sign, which may be different from any programming language you are familiar with.At the same

Connectors in the shell (and, and, or)

&& (and) with the || (OR) with the ; (and)A semicolon has just been mentioned above for the delimiter between multiple commands. There are also two special symbols that can be used in the middle of multiple commands, that is, "&&" and "| |" are all

Shell Find command detailed

Find FilesFind./-type FFind a DirectoryFind./-type DFind a file or directory with the name testFind./-name TestLook for a file whose name matches the regular expression, and note the preceding '. * ' (found file with directory)Find./-regex.

Data structure and algorithm--advanced sort: Shell sort and quick sort "to be Continued"

Advanced sorting is much faster than simple sorting, the time complexity of simple sorting is O (n^2), and Hill (shell) sorts O (n (logn) ^2), and quick Sort is O (N*logn).Note: The following is an example of a small to large sort of an int

Total Pages: 541 1 .... 284 285 286 287 288 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.