1. Determine if a file is a block or character device file, and if it is copied to the/dev directoryRead-p "Input a file:" filenameIf [-B $filename-O-C $filename]ThenCP $filename/dev/Fi 2. Write a script to perform a simple subtraction operation
1. In the current directory, look for the files that were accessed within 20 minutes, and display the details of the file:Find./-name ' *.log '-mmin-20-exec ls-l {} \;Note: where {} is replaced by the file name, and the colon is used to indicate
1, dirs1) Functiondisplays all records in the current directory stack (the dirs command with no parameters displays the records in the current directory stack)2) Syntax(1) format: dirs [-CLPV] [+n] [-n](2) Options-C Delete all records in the
There are two ways that Linux shell executesShell scripts start with #!/bin/bash, and the shell is executed with the first row checked and executed internally in the following ways:$/bin/bash script.sh1. Execute with SH.$sh script.sh #脚本位于当前目录下Or$sh/
[grep profile : ]grep is used to filter lines that contain specific charactersusage: grep ' pattern ' fileFor example: grep ' BBB ' aaa.txt--color # Search for the keyword BBB from the file Aaa.txt and highlight it.[Regular meta-character :
Linux class Assignment Wednesday, if there is a poor consideration to the place, also please advise.Shell Processing Text See this blog for common commands related to##如果输入两个参数 is the first to count the number of words, the second is the article to
The case structure in bash, which can be used for multiple branches.Case "$ Var" inCondition1);;Condition2);;*)Default statments ;;EsacFor example:#! /Bin/bashEcho "hit a key, then hit return"Read keypressCase "$ keypress" in[A-Z]) echo "uppercase
1). Background:During cluster deployment, consistent configuration and environment settings are required. for Virtual Machine clusters, you can copy, copy, and restore cluster machines by using images. different from physical machine clusters, if
Script: the source program implemented by the command flow control mechanism based on the actual situation.
Script description:
1. Start with shebang, that is #! /Bin/bash. The path of the script interpreter is specified here. 2. Comments starting
Single branch if statement
If condition; then statement1 statement2fi
Dual-branch if statement
If judgment condition; then statement1 statement2 ...... Else statement3 statement4 ...... Fi
Multi-branch if statement
If condition 1; then statement1
After a netizen watched the old boy's shell video today, he asked the following question:
650) This. width = 650; "Title =" snap17.jpg "alt =" wkiol1oz8i_gwllfaaetvavr46c745.jpg "src ="
8.1 count disk usage
1. Disk Space is a limited resource.
2 df and du are important commands used in Linux to measure disk usage. df is short for disk free and du is short for disk usage.
3. Find the disk space occupied by a file (or multiple files):
#! /Bin/bashNAME = javaNOP =/bin/trueDATE = $ (/bin/date + "% Y-% m-% d % H: % M: % S ") ps-ef | awk-F "" '{print $8, $2}' | grep ^ java>/dev/null 2> & 1 case "$? "In0) # It is running in this case so we do nothing. echo "$ NAME is running OK. relax.
In the shell command terminal, Ctrl + n is equivalent to the downward direction key, and Ctrl + p is equivalent to the upward direction key.
You can use them or the arrow keys in the Command terminal to quickly find historical commands. This is
LINENO
The row number of the script or shell function currently being executed.
LINES
The select command is used to determine the width of the selected columns. After receiving SIGWINCH, It is set automatically.
MACHTYPE
Is a string that
Loop Control Structure of shell script Programming
Loop Control-for Loop
Syntax 1
For Variable in List
Do
Commands
Done
Syntax structure 2
For Variable in List; do
Commands
Done
This List can be a List, variable, command, etc.
A for Loop provides an
In some scenarios with high security requirements, the ssh timeout period is preset by the Administrator. After a period of time, the ssh connection is automatically disconnected. In this case, if you execute the script through ssh and the script
1: grep command:
Grep-v "char" file_name match text that does not contain "char"
Grep-n-w "char" file_name completely matches a character
Grep ^ s $ s is the text that matches the first or last row of s.
2: tr command
Tr set1 set2 replace set
Conditions are required for exporting data from mongodb
Currently, time is stored in milliseconds. Therefore, you must obtain the number of milliseconds from the shell.
The first thing to say is the + % s parameter of the date command.
I searched
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