Linux command example

Source: Internet
Author: User
Linux command example Untitled operator: redirection: & gt; (overwriting) & gt ;! (Force overwrite) & lt; (input) & gt; (append) 1 & gt; (filter out the correct information, input; 1 & gt; overWrite) 2 & gt; (filter out error message, input; 2 & gt; overwrite) example: ls-al1 & gt;/home/a.txt 2 & gt; /home/. linux command example Untitled operator: redirection:> (overwriting)>! (Force overwrite) <(input)> (append) 1> (filter out the correct information, input; 1> overwrite) 2> (filter out the error message and input it; 2> overwrite) example: ls-al 1>/home/a.txt 2>/home/. err note: in the ls-aloutput information, the contents are overwritten to a.txt, and the errors are overwritten to. pipeline in err: | cat (content of one-time input file) cat-n/home/a.txt note: add the line number cat-B/home/a.txt before the output file content note: add a row number (Ignore blank lines) to the content of the output file cat>/home/a.txt <sign note: edit mode, run the "sign" symbol to end cat>/home/a.txt <sign note: edit mode. run the "sign" symbol to end (append) more (display file content by page) more + num (displayed from row num)-num (row num is displayed on each page) +/pattern (displayed from the first two rows of pattern matching) )-C (clear screen, displayed from the top)-d (realistic prompt message: space continues, q exits)-l (ignore pagination character) more +/1234/home/a.txt note: the first two rows in a.txt that match 1234 words are displayed. note: Ctrl + f or blank space key scroll down one screen; Ctrl + B scroll up one screen; = output the row number of the current row;: f output file name and the row number of the current row ;! Command to call shell command less (pagination of real file content) less-c (clear screen, displayed from the top)-f (forced open, no warning for binary files) -I (case-insensitive for search, unless there are uppercase letters in the search string)-I (case-insensitive for search, unless there are lowercase letters in the search string)-m (actual percentage) -M (actual percentage, row number, total number of rows)-N (the row number is displayed before each row)-p pattern (the content matching pattern in the highlighted file) -s (consecutive blank rows are displayed as a blank row) Note: y: scroll up a row; space: scroll down a screen; B: scroll up a screen; d: scroll down half screen; u: scroll up half screen; w: show from the next line of the input line number; g: Jump to the input line number; G to the last line; P n %: starting from the n % of the file ;! Command (for example :! Ls displays all files in the current directory) head (displays the first few lines of the file content) head-n 2/home/a.txt note: display the first two lines of the.txt file tail (the last lines of the file content) tail-n 2/home/a.txt note: display the last two lines of the.txt file cut (pipeline command) cat/home/a.txt | cut-d ','-f 2 Note: Use commas (,) to separate (-d ',') in each line in the.txt file ','), extract the second element of the split array (-f 2) last | cut-c5-10 note: extract the 5th to 10 characters of each line in the last Output Content (-c 5-10) and output the sort (pipeline command, sort by character by line) cat/etc/passwd | sorc-t': '-k2, 3 note: divide the content in the passwd file by': '(-t ':', split the array number from 0), and then sort it with 3rd elements (-k2, 3) to 4th elements; Cat/etc/passwd | sorc-t': '-k2, 3r note: divide the content in the passwd file by': '(-t ':', split the array number from 0), and then sort the array (-k2, 3) elements to 3rd elements in reverse order; wc (pipeline command, File statistics) cat/home/a.txt | wc-l note: counting the number of lines in the.txt file cat/home/a.txt | wc-w note: statistics on the number of characters in the.txt file cat/home/a.txt | wc-m note: The number of characters in the.txt file uniq (pipeline command, delete repeated lines) cat/home/a.txt | cut-d ", "-f1 | sort | uniq Note: only the first ', 'contents before commas (,) in each line in the.txt file are displayed, sorted, and duplicated lines are deleted (pipeline command, redirect File, data is displayed on the screen) cat/home/a.txt | tee/home/. bak. Txt note: redirect the content of the "cat/home/a.txt" command output to the.bak.txt file and display the content on the screen (difference: cat/home/a.txt>/home/a.bak.txt is not displayed on the screen) tr (pipeline command, delete or replace "character") tr-c-d-s ["string1"] ["string2"] replace string1 with string2, note: "123" ---> "abc", replace 1 with a, 2 with B, 3 with c, and "321" with "CBA ", it operates on "characters ". -D: delete all input characters in string1. -S deletes all recurring character sequences and retains only the first one. The recurring characters are compressed into one cat/home/a.txt | tr "12" "AB" note: replace 1 and 2 Characters in a.txt with cat/home/a.txt | tr [a-z] [A-Z]. note: replace lowercase letters in a.txt with uppercase letters cat/home/a.txt | tr [A-Z] [a-z] Note: replace uppercase letters in the.txt file with lowercase letters cat/home/a.txt | tr [0-9] [a-j]. note: replace 0-9 in the.txt file with the lowercase letter a-jcat/home/a.txt | tr-d '123'. note: delete all the characters "cat/home/a.txt | tr-d" \ t \ n "in the.txt file. note: delete all the characters cat/home/a.txt | tr-s 'Ace 'in the.txt file. note: ensure that the characters a, c, and e in the.txt file are consecutively duplicated, delete duplicate files. Only one split (pipeline command, split file) split-B 100/home/a.txt a_split is retained. note: The a.txt file is separated, and each 100 bytes is separated by the following file names: split-l 100/home/a.txt a_split starting with a_split note: The a.txt file is split into 100 rows. the split file name starts with a_split and dmesg (displays hardware loading and other log information) lsusb (list usb devices) lsmod (list models)

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.