Linux Command Line Text processing tool

Source: Internet
Author: User

Linux Command Line Text processing tool based on the keyword search command grep is used to search text Command Format grep "keyword" based on the keyword, and is usually used with the pipeline, such as ls-l | grep "test ". the following are common parameters: I ignore the case when searching.-n shows the row where the result is located.-v outputs the row without the keyword.-Ax contains the row where the result is located after the output (after) the specified number of rows-Bx contains the specified number of rows before the result row (before). The cut command is used to process the text based on the column text content. Example: cut-d: -f1/etc/passwd: Use ':' as the delimiter and output the first column, which separates the/etc/passwd file, the following are common parameters:-d specifies the delimiter (TAB by default)-f specifies the output column number-c Based on words for cutting, for example, cut-c2-6/etc/passwd, that is, the output of each line of/etc/passwd, the 2nd to 6th characters of the text statistics command wc Force Statistics text information examples: such as wc OK. cpp. The following are the displayed results and explanations 9 23 96 OK. number of cpp lines, 9 words in total, 23 words in total, 96 bytes in total, called OK. cpp the following are common parameters-l only count the number of rows-w only count the number of words-c only count the number of bytes-m only count the number of characters text sorting command sort to sort the text content examples: for example, sort file-r sorts data in reverse order-n sorts data based on numbers-f ignores case-u deletes duplicate rows-t c uses c as the separator for column sorting-k x specifies which sort keys, it is usually used to sort columns based on specified characters, the sort-u command can be used to delete duplicate lines. The uniq command is used to delete duplicate adjacent lines. The comparison command diff is used to compare the differences between two files. The following are common parameters. -I ignore case-B ignore the number of spaces change-u display the comparison information (usually used to generate patch files) check spelling command aspell to display check English spelling process text content command tr to process text content delete keyword tr-d "TMD" <file to convert uppercase and lowercase tr 'a-z'' a-z 'File search replacement command sed is used to search for and replace files, here is a good tutorial. The following lists some common usage of sed's/old/new/G' file to replace the old word in file with new, if multiple old objects exist in the same row, change each old object to new sed '1, 50 s/old/new/G' file, and change the old objects in each row from 1 to 50 to new, if multiple old objects exist in the same row, change each old to new sed-e's/old1/new1/G'-e's/old2/new2/G' file and run the following command' and the 's/old2/new2/G' commands sed-f sedsrcept file execute the commands in the sedscept script on the file

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.