Common text Editing commands

Source: Internet
Author: User
Tags diff


1.diff Comparison of two different files

Diff-u file file.new >file.path## generating patch files

Yum Install patch-y## installation Patching tool

Patch-b file file.path## to old software patching, clear and backup of old software

2.grep## Filter Characters

-i## or slightly case

-n## The line number of the row where the result is displayed

-c## Number of results

-v## Reverse Filter

-r Keyword Directory # # filter files in the directory with keywords

-E " keyword 1| keyword 2| ... "# # filter Multiple keywords

3.sort## Sort

-n## Pure Digital

-r## Reverse

-u## Remove Duplicate rows

-t## specifying delimiters

-k## To specify a sorted column

4.uniq## processing Duplicate rows

-c## count the number of repeating rows

-u## display Unique rows

-d## Show Duplicate rows

5.tr## convert character case

Tr ' A-Z ' A-Z ' <file## converts all lowercase characters in file to uppercase

6.sed (-I for synchronizing changes to the original file ) # # Control Flow output

Sed ' s/nologin/westos/g ' passwd # # Replace the Nologin in the output as Westos

Sed ' 1,5s/nologin/westos/g ' passwd # # Replace the nologin of 1-5 lines in the output as wesots

Sed '/games/,/nobody/s/nologin/westos/g ' passwd## replaces the nologin of the Games characters in the output to nobody characters To Westos

Sed-e ' s/nologin/westos/g '-e ' s/sbin/lee/g ' passwd## multiple substitution policies with- e connection

Sed 3d passwd## does not display the third row in the file

Sed 3,7d file## does not display 3-7 lines in a file

sed 3,7p File # # repeats 3-7 lines in Files

Sed-n 3,7p File # # displays only 3-7 lines in the files

[[email protected] mnt]# Cat rule # # rule File Contents

S/nologin/westos/g

S/sbin/lee/g

[[email protected] mnt]# sed-f rule File # # change output using rule files

1root:x:0:0:root:/root:/bin/bash

2bin:x:1:1:bin:/bin:/lee/westos

3daemon:x:2:2:daemon:/lee:/lee/westos

4adm:x:3:4:adm:/var/adm:/lee/westos


Common text Editing commands

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.