CutThe Cut command extracts text columns from a text file or text stream.Cut grammar[[email protected] ~]# cut-d ' The delimited character '-f fields options with Parameters: -D: followed by delimited characters. Use with-F; -F: Divides a piece of
awk '/5/{a=1}!a ' file2Results:1234Explain:The first line/5/does not match skip {a=1}, continue to!a, at which point a no value belongs to the false take reverse to true, so the first line of outputThe second line/5/does not match skip {a=1},
1. Set the environment variable histsize so that it can save 10,000 command history. vim/etc/profile change histsize=1000 to histsize=10000 2. Why do I set PS1 (ps1= "[\[email protected]\h \w]\$") display the results to be different from
Requirements: The company has two backup servers, one from the beginning, every night from the server began to synchronize some data on the main service, but rsync always disconnected, tried a lot of methods are useless, wrote a script to solve this
1. Read a row of data using the Read commandWhile read Mylinedo echo "line:" $mylinedone 2. Read a row of data using the Read commandCat Datafile.txt | While read Mylinedo echo "line:" $mylinedone3. #读取一行数据Cat Datafile.txt | While myline=$ (line)
Condition test:To determine whether a demand is satisfied, it needs to be realized by testing mechanism;How to write a test expression to implement the required tests:(1) Execute the command, and use the command status return value to judge;$?:
Scenario: Fake tune There are several files like this in your directory1.jpg?v=12.jpg?v=23.jpg?v=34.jpg?v=4What if the v=x of the file is removed?Method One: Direct write command implementation using AWK shell command implementationls | awk ' {split
The while loop is used to continuously execute a series of commands and to read data from the input file; the command is usually a test condition. The format is:While Commanddo Statement (s) to being executed if command is TruedoneThe command
Reference parameters
Describe
0,1,2.
Positional parameters. Start with the parameter 0. The parameter 0 references the name of the Startup bash program, and if the function runs in the shell script, the name of the shell
Open a text editor, create a new file, the extension sh (sh for Shell), the extension does not affect the execution of the script, see the name is good, if you write a shell script in PHP, the extension is good with PHP.Enter some code:
The common check parameters are as follows:Operator If ... True-b file file is a block device file-c file file is a character device file-d file file for directory -e file file exists-F
In a POSIX shell environment, eval is used to remove a string when the parameter option is used, and the effect is the same as "'", which is useful when writing large numbers of references to more complex scripts. The simple use of bash, usually
Filter GawkGawk is a language that can perform pattern scanning and data processing. Gawk searches for one or more files, finds records (usually rows) that match the pattern, and processes the records by performing the specified actions.
Gawk
With "'"""todayis" ' date ' preceded by a character, followed by ' date ' Represents the Execute Date command. PDATE=""'date'is Date" Expr " is used to calculate the result of a=9b=tenvar1= $a +$becho $var 1 output is "9 +10"expr" is used
Shell types: Bourne shell, Bourne Again shell, C shell, Korn shell, Perl shell
Users can choose their favorite shell (specified when the system administrator creates an account for the user), and in the last field of the/etc/passwd file, you can
1. Bash = Bourne Again SHell2. Terminal prompt:#普通用户 [email protected]$ #管理员用户 [email protected]#3. The shell script is usually a text file that starts with Shebang:#! /bin/bashShebang is a line of text where #! is before the interpreter path.
Enterprise Shell interview questions: Get 51CTO Blog list Reverse sort exam questionsOld boys education and training institutions demand: the need to enter:Please put all the posts in the http://oldboy.blog.51cto.com address according to 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