Shell commandsXargs
Build and execute command lines from standard input
Xargs can be readStdinAnd use a space character or line break character as the resolutionStdinData is separatedArguments.
1) Description
Xargs [-0epn] command
Options
20. Use the shell command in the pipeline to obtain system running data:
1. output the five commands that occupy the most memory in the current system : #1) run the ps command to list all processes running on the current host. #2) The fifth
1. FTP automatically logs in to batch download files.
##### From/home/data on the FTP server to the local/home/databackup #####! /Bin/bashFTP-n Open 192.168.1.171User guest 123456.BinaryCD/home/DataLCD/home/databackupPromptMget *CloseBye!2. FTP
> VI copy and paste
Move the cursor to the beginning of the part to be copied. Run ESC to exit the insert mode. Press V to enter visual mode. Use hjkl to select the part to be copied.
Press Y or YY to copy
Move the cursor to the target
Previous
We all know that Linux Shell is very powerful in text processing. There is a powerful set of text processing tools: grep, sed, awk. Grep is often used for searching and matching text and SEDCompositionThis edited replacement and awk are
## Check the PID of such program#Checkpid (){If [-z "'ps X | grep $1 | grep-V grep | grep-V $0 | awk '{print $1}'' "]; thenEcho "the $1 program cant run well ."Fi}
Simple Description:
PS reportProgramStatus.
Ps x shows all programs,
Replace file1 with the actual file as follows
1. query the row number of the empty row in file1.Grep-n "^ $" stl_stable_sort.ccRefer:Common grep commands
2. query the rows ending with ABC in file1.Grep-n "^. * ABC $"
Before scripts runs, the most feared problem is the syntax error! So how can we debug it? Is there a way to determine whether there is a problem without directly running the scripts? Haha! Of course! Let's take the bash-related parameters for
Conditional Criterion
Just talk about 『Program", Then the conditional criterion, that is, the criterion" If then ", must be learned! Because in many cases, we have to determine how the program should proceed based on certain data.
If... then
7. grep family:1. grep exit status:0: indicates successful;1: The matching pattern cannot be found in the provided file;2: The file provided in the parameter does not exist.See the following example:/> Grep 'root'/etc/passwdRoot: x: 0: 0:
When accessing the ps1 file, be sure to check whether the access path contains spaces.
Spaces must be enclosed in single quotes.
PowerShell-command Set-ExecutionPolicy "Bypass" set filepath = '% CD % \ AppDeployment. ps1 'powershell-command "& %
Copy codeThe Code is as follows: # include
Using namespace std;
Void ShellQin (int A [], int n)
{
Int gap = n/2;
Int I, j;
For (; gap> 0; gap = gap/2) // set the initial gap, group by gap, and decrease by gap/2
{
// After the gap is set, insert and
Shell script:
1 ,#! Shell for Script Execution2. # comment3. Command or syntax structureEcho "input content"Empty line output by echo
Run:
1. shell scriptSh example2. Grant shell script execution permissionChmod u + x example
Case: example sysinfo.
&&Command 1 & command 2: If the command is successfully executed, run the command.[Jb]/usr/xxxx/ytcclb> ls-l test. SQL-Rwxr -- r -- 1 xxxx group 225 Nov 15 test. SQL[Jb]/usr/xxxx/ytcclb> cp test. SQL test. bak & echo "coping file OK! "Coping file OK!
1. Methods of raw violence
Copy codeThe Code is as follows: myLinux:/home/zhanhailiang/public_html # killall nginx
2. gentle approachFind the pid of the specified process and kill | kill-USR1
Copy codeThe Code is as follows:
Bash shell supports only one-dimensional arrays, but there is no limit on the number of parameters.
Declare an array:Declare-a array(In fact, you don't need to declare it. You just need to assign values to variables in the array mode. BASH knows
Extract the alert log shell script of oralce on the current day
Copy codeThe Code is as follows: #/bin/sh
# Get alert of everyday
# Then name of file is everyday_alert.sh
Dir = "/oracle/admin/bbdz/bdump"
Num = $ (cat-n $ {dir}/alert_bbdz.log |
Back up website content
Copy codeThe Code is as follows :#! /Bin/bash
# Specify the running script shell
# Run the script to grant the user the execution permission
Bakdir =/backup
Month = 'date + % m'
Day = 'date + % d'
Year = 'date + % y'
4.1 sort text
4.1.1 sort rowsIf the command line option is not provided, the entire record is sorted by the order defined by the current locale.In the traditional C locale, that is, the ASCII order.
4.1.2 sort by fieldsThe-k option is followed by 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