Linux Command Script

Source: Internet
Author: User

1. xargs

Xargs
More practical applications $
Ls | xargs-t-I MV {}{}. Bak
-The I option tells xargs to replace {} with the name of each item {}.

Parameter Parsing:
T ----------------- print out the command before executing
I ------------------ Replace with the file name {}


Delete a large number of files
Ls | xargs-N 20 Rm-fr
Parameter Parsing:
N ----------------------- N number indicates how many ls outputs are taken as a group and used as the parameters of the subsequent commands.
Ls is of course the output of all file names (separated by spaces)
Xargs refers to the output of LS, every 20 are a group (with space as the separator), as the RM-RF parameter, that is, 20 are all file names, deleted by RM-RF, this will not exceed the length of the command line.

2. awk

Purpose
Finds lines in files that match a pattern and performs specified
Actions on those lines.

Translate to Chinese:

Purpose:

Find a row that matches a format in the file and perform the specified operation on the row.

Syntax:

Awk [-u] [-F ere] [-V Assignment]... {-F programfile |
'Signature'} [[file... | assignment...]...

-F option to specify the field separator

Example:

Awk-F ":" '{print "username:" $1 "uid:" $3}'/etc/passwd

Specify: As the field separator of the file

X = 'df-k a file system | awk-f''' {print $4} '| grep-V used | SED's/% //''

Ignore syntax


3. Sed

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.