Linux Getting Started Basics--linux command line Text Processing tool

Source: Internet
Author: User
Tags diff processing text

Linux command line Text Processing tool file Browse Cat view file contents
More view file contents as page flipping (page down only)
Less view the contents of a file as a page turn (page up or down)
Head view the beginning of the file 10 lines (or the specified number of lines)
Tail View the end of the file 10 lines (or the specified number of lines)
Search based on keywords
command grep to search for text based on keyword-I ignores case when searching
-N Displays the number of rows in which the result
-V Output lines without keywords
-ax the specified number of rows after the row of the result is included in the output
-BX the specified number of rows before the result row is included in the output
grep "Hello"./*
Finds rows in all documents in the current directory that contain the Hello keyword
The command cut is used to specify the delimiter based on the column processing text content-D (tab is the default)
-f Specifies the column number of the output
-C segmentation based on characters
Cut-d:-f1/etc/passwd
grep liu/etc/passwd | Cut-d:-F3
Cut-c2-6/etc/passwd (only 2nd to 6th characters shown)
Command WC to statistic text information-L only count rows
-W only count words
-C only counts bytes
-M only counts the number of characters
Command sort to sort text content-R for reverse order
-N Sort By numbers
-F ignores case
-U Delete Duplicate rows
-T C uses C as a delimiter to sort columns
-K x specifies which column to sort based on when the column is sorted based on the specified character
Command sort-u can be used to delete duplicate rows
Command Uniq to delete duplicate rows (only adjacent duplicate rows can be deleted)
command diff to compare the difference between two text files-I ignores case
-B ignores changes in the number of spaces
U Unified Display of comparison information (typically used to generate patch files)
Diff-u Test test-new > Final.patch
Command Aspell to display the check English Spelling command tr to process the text content delete keyword
Tr-d ' TMD ' < filename
Convert case
Tr ' A-Z ' A-Z ' < filename
Command sed to search for and replace text sed ' s/linux/unix/g ' filename (g is global replacement, Linux is replaced by Unix)
Search for replacements using regular expressions
Sed ' 1,50s/linux/unix/g ' filename

Linux Getting Started Basics--linux command line Text Processing tool

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.