Similar to awk Functions
Example 1
$ A = 'echo root: X: 0: 0: Root:/root:/bin/bash | cut-D: -F 1,5 'shuohailhl @ shuohailhl-PC/cygdrive/d $ echo $ aroot: Root
In the preceding example, the root: X: 0: 0: Root:/root:/bin/bash command is
Basename is the name left after the directory is removed.Example: shell> temp =/home/temp/1. TestShell> base = 'basename $ temp '(reverse quotation marks)Shell> echo $ BaseResult: 1. TestDirname is the DirectoryExample: shell> temp =/home/temp/1.
/*************************************** ******************************* Author: Samson* Date: 08/18/2012* Test Platform:* GNU Linux version 2.6.29.4* GNU bash, version 4.0.16 (1)-release (i386-redhat-linux-gnu)
************************************
Example about Linux Shell #! /Bin/bash echo "Hello world! " echo" Hello $ LOGNAME, it's nice talking to you " echo" U present working on a machine is 'uname-N' " echo" U Present working directory is $ (PWD) " echo" Bye for now $ LOGNAME. the time
1. String Truncation
(1) intercept the string before and after a specified character
[Root @ gd86 applications] # Var = Hello: zkl: zyh
[Root @ gd86 applications] # echo $ {var %: *} returns the first string from right to left.Hello: zkl[Root @
Difference between $ * and $ @ in Shell
A little bit about $ * and $ @ is also learned by cainiao.
$ *All location parameters are used as a word.Note: "$ *" must be referenced.$ @It is synonymous with $ *, but each parameter is an independent ""
Unix shell programming (4)
Cut commandYou can extract the required data fields from the data file or command output.Command Format: Cut-cchars FileChars indicates the characters to intercept, which can be numbers.File indicates a file. If file is
This article summarizes some of my frequently used shell commands or some short commands.
1. view the compile time of a tool;
ll $(which appname)
2. Common for Loops
for i in 1 2 3 4 5; do echo "$i"; done;
for((i=140;i
3. Commonly Used File
Common grep command syntax 1. Double quotation marks and single quotation marksWhen you input a string parameter in the g r e p command, it is best to enclose it with double quotation marks. For example, "m y s t r I n g ". There are two reasons for
When I went to bed in chemistry today (Khan ......) dreaming, dreaming of penetrating a magic = off PHP injection point, and then happy mouth water flow (..... sleep too much), suddenly woke up, and immediately wrote the dream idea on the paper:
Mycommand> mylog.txt 2> & 1 should be the most classic usage.
Command results can be output in the form of "%>", % indicates the file descriptor: 1 indicates the standard output stdout, and 2 indicates the standard error stderr. The default value of
1. Using securitycrt in the options-> session Options dialog box, there are many options for emulation under terminal. the Linux server has different terminal simulation packages called the terminfo database, each type corresponds to a terminfo File
/*************************************** ******************************* Author: Samson* Date: 08/17/2012* Test Platform:* GNU Linux version 2.6.29.4* GNU bash, version 4.0.16 (1)-release (i386-redhat-linux-gnu)
**************************************
Linux scripts are huge and powerful.
Definition:
Function Name () // function can be omitted
{
Command
}
Call: directly use the function name in the script. Of course, you can also include parameters such
Function Name parameters (separated by
In Shell, only one process can be implemented at a time:
1. lockf command
2. Simple implementation:
I = 'ps-Ef | grep [N] ew_mvbackup | WC-l' if [$ I-GT 1];ThenEcho "wait for the other mvbackup finish! "Exit-1Else
# Do something here
3.
The most important script language in Linux is Bash. I will write this (I will only use this :)). Compared with other development languages (such as C), bash is a relatively simple language, mainly used to write some script code, some batch
1. Write a script to calculate the factorial of 10 in a loop.
#! /Bin/sh factorial = 1 for a in 'seq 1 10' DO factorial = 'expr $ factorial/* $ a' done echo "10! = $ Factorial "
2. Write a script. After the script is executed, print a
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