Linux basics: Command Line Text processing tools

Source: Internet
Author: User
Tags processing text

Linux basics: the command line text processing tool uses the keyword-based search command grep to search text $ grep 'shuangde'/etc/passwd $ find/-user shuangde | grep Video-I is ignored during search case-n: display the number of rows in the result-v: Output rows without keywords-Ax: output contains the specified number of rows after the row where the result is located-Bx contains the row before the result is output the specified number of lines based on the column processing text command cut is used to process text content based on the column $ cut-d: -f 1/etc/passwd are separated by colons and the first column of the passwd file is displayed (if multiple columns are displayed:-f, 3) $ grep shuangde/etc/passwd | cut-d: -f3-d specify the delimiter (TAB by default)-f specify the output column number-c Split Based on characters $ cut-c2-6/etc/passwd display 2nd ~ 6-character text statistics command wc (word count) is used to collect text information $ wc file output line, number of words, number of bytes-l (lines): only count the number of lines-w (words): Count only the number of words-c (bytes): Count only the number of bytes-m (chars): Count only the number of characters. Text sorting sort command: used to sort the row content of text (only English and numbers are supported) $ sort filename-r reverse sort-n sort by number-f ignore case-u Delete duplicate rows-t c use c as separator to split into columns for sorting-k x when based on when the specified characters are separated into columns for sorting, specify the columns to sort and delete duplicate rows $ sort-u. You can delete duplicate rows $ uniq to delete adjacent duplicate rows. The command compares diff text: compare differences between two text files one line by one $ diff file1 file2-i ignore case-B ignore the number of spaces change-u uniformly display compare information (typically used to generate patch files) $ diff-u file1 file2> final. patch spelling check aspell command: Display check English spelling $ aspell check file check the spelling of words in the file, you can correct $ aspell list file to put the wrong words in the file, and display the tr command for processing text content: change or delete the text content to delete the keyword $ tr-d 'tmd '<filename to T, M, d. Delete all three letters and convert them to uppercase and lowercase. $ tr 'a-Z' <filename search to replace sed command: used to search for and replace text (stream editor for filtering and transforming text .) $ sed's/linux/unix/G' file $ sed '1, 50 s/linux/unix/G' file $ sed-e's/linux/unix/G'-e's/hehe/haha/G' file can specify multiple matches mode $ sed-f sededit 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.