The $ symbol in Bash is used to replace the parameter name with the value represented by the parameter. For $, braces are optional, that is, $ A and $ {A} represent the same parameter. $ {} There are several expressions with colons: $
The case expression can be used to match a given string, not a number (do not confuse switch... case in C ).
Case... in...) do something here esac
The file command can identify the file type of a given file, for example, file lf.gz. The output
FTP-I-v-n
FTP download, open IP port is the connection server, User Username Password is the login, CD/admin is the CD to the Admin directory under the FTP server, LCD D: /Shell/data is used to change the local working directory to the
Shell script debugging-run log 1
This article mainly describes how to output debug logs in shell scripts.
C/C ++ debug log
In C/C ++, _ file __, _ FUNC __, _ line _ indicates which log of the current row comes fromSource codeWhich
A simple shell Backdoor
Author: Pony/smallhorse [e.s. t VIP] (it doesn't matter if you do not write this e.s. t VIP)Source: evil baboons China
Recently, I was bored and thought about writing a simple shell backdoor. At the same time, anti-virus
1. Get user input.The parameter is the regular expression that is correctly checked by the input prompt, and the default value is entered.ReturnThe correct user input is returned.
Function get_input (){Prompt = $1RegEx = $2Default = $3If ["x $
#! /Bin/bash
A = "one, two, three, four"
# To split $ A, you can:
Old_ifs = "$ ifs"
Ifs = ","
Arr = ($)
Ifs = "$ old_ifs"
For s in $ {arr [@]}
Do
Echo "$ S"
Done
The above code will output
One
Two
Three
Four
Arr = ($ A) is used to
Note: No space is allowed between the left and right sides of "=". The semicolon program 1 # is not required at the end of the bash statement #! /Bin/sh # echo somethingecho "Hello World" Echo "Hello !! "CD/root/export topmkdir./ABC Program 2,
$1 indicates the first parameter. $ * indicates all parameters entered by the user.
The hello1 script is as follows. A location parameter is acceptable.
#! /Bin/bash
Echo $1
Run the Script:./hello1 "Hello World" and output Hello World on the
This script was modified on the cache cleanup script of Zhang banquet, mainly to add the if option, and select the address of the cached file based on the $1 parameter type (because $1 is not fixed, sometimes it is a specific JPG type, sometimes it
1)
Create
FunctionName {
...
}
Or:
Name (){
...
}
2)
Call
Use the function name directly. The function can be called only after it is defined;
When a function has the same name, the new definition will overwrite the old definition and no
Ls
-L, show the hard link count;
-I, show I-node
-H, human readable
-T, sort by modify time
-S, sort by size
-R, -- reverse
-R, show content of sub-Dir
-V, sort by version
CP
-P,Retain source file attributes, such as the modification time
-L,
In awk programming, do not forget that awk processes regular expressions. There are many internal functions, especially string processing functions. Calling these functions can reduce the workload.
1. Format
// Note \ There cannot be spaces behind
I don't know when I wrote something, But I was found by archaeology when I sorted out the documents. I just smiled at those people who were bored. If the errors in this article cause all mental losses to you, contact the insurance company! Of course
Unix shell programming
Summary of some conditions
-B file: if the file exists and is a special block file, it is true.-C file: if the file exists and is a special character file, it is true.-D file: if the file exists and is a directory, it is true.-
Shell script used to detect Processes
10:38:08 | category: centos | font size subscription
Script 1:
#! /Bin/sh
Program = XXXX # process name
Sn = 'ps-Ef | grep $ program | grep-V grep | awk '{print $2} ''# obtain the process port numberIf ["$ {sn}"
#! /Bin/sh
# Filename: 2.sh
B = 9
E = 15
Tmpb = $ B
While [$ tmpb-Le $ E]
Do
Echo $ tmpb
# Tmpb = 'expr $ tmpb + 1' // OK
Tmpb = $ (expr $ tmpb + 1)
Done
After the script is executed, the output result is:
9101112131415
Note: 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