Write in front: the blogger is a real combat development after training into the cause of the “hill pig”, nickname from the cartoon “Lion King” in “Peng Peng”, always optimistic, positive attitude towards things around. My technical path from Java full stack engineer all the way to big data development, data mining field, now there are small achievements, I would like to share with you what I have learned in the past, I hope to help you on the way of learning. At the same time, the blogger also wants to build a perfect technical library through this attempt. Any anomalies, errors and matters needing attention related to the technical points of the article will be listed at the end, and everyone is welcome to provide materials in various ways.

  • Please criticize any mistakes in the article and revise them in time.
  • If you have any questions you would like to discuss or learn, please contact me at [email protected].
  • The style of the published article varies from column to column, and all are self-contained. Please correct the deficiencies.

Beginners will be Linux command – file view

Keywords: Linux, common commands, file view \

The article directories

  • Cat: View the file content
  • More: Displays file contents in paging mode
  • Less: files can be viewed in separate pages and can be flipped back repeatedly
  • Head: View the file header
  • Tail: View the tail content of a file
  • Wc: displays line, word, and byte statistics of a file
  • Grep: Finds the keyword and prints the matching line
  • Echo: Displays a specified line of text

A, the cat

Viewing file Contents

  • Usage: cat [option] [file]

    • -b: displays the line number. Blank lines are not displayed
    • -n: Displays the line number, including blank lines

Second, the more

Page to view the file content, by space to view the next page, by press Enter to view the next line, q to exit the view

  • Usage: more [option] [file]

    • -d: Displays a prompt message. Otherwise, only a prompt tone is heard
    • -s: Merges blank lines with more than two lines to improve reading efficiency
    • +num: displays from line num
    • -num: specifies the number of lines to be displayed on a page
    • +/ PATTERN: Searches for the pattern string before displaying it, and displays it starting near the location
  • Enter reading mode

    • Enter: Scroll down 1 line
    • Space: Scroll down one screen
    • Ctrl+B: Return to previous screen
    • = : Displays the line number of the current line
    • Q: quit





Three, less

Page to view the file content, through the space to view the next page, arrow key back up and down, Q exit view

  • Usage: less [option] [file]

    • -e: Automatically leaves when the file is displayed
    • -n: Displays the line number of each line
  • Enter reading mode

    • Enter: Scrolls a line
    • Space: Scroll a page
    • / string: looks down the specified content
    • ? String: Looks up the specified content
    • B: Turn back a page
    • D: Turn back half a page
    • Q: quit

Fourth, the head

View the content in the file header. The first 10 lines are displayed by default

  • Usage: head [option] [file]

    • -c nK: Displays the nKB content before the file
    • -n: Displays the first n lines of a file

Five, the tail

View the end of the file. By default, the last 10 lines are displayed

  • Usage: tail [option] [file]

    • -c nK: displays the nKB content at the end of the file
    • -n: Displays the content in the n lines at the end of the file
    • -f: displays the contents of the file dynamically (continuously reading the contents at the end of the file). Press Ctrl+C to exit

Six, wc

Displays file, word, and byte statistics

  • Usage: wc [option] [file]

    • -c: displays file byte statistics
    • -l: Displays the statistics on the number of file lines
    • -w: Displays the statistics of file words

Seven, grep

Find the keywords and print the matching lines

  • Use: grep [options] match pattern [file]

    • -i: case is ignored
    • -v: Indicates the reverse match
    • -w: matches the word
    • – color: displays the color

Eight, the echo

Displays the specified line of text

  • Echo [option] [string]

    • -n: does not output newlines (default echo output will be newlines)
    • -e: supports the escape characters starting with backslashes and hides the original meaning of the characters following backslashes
\\ backslash \ A alarm \b Backspace key \f Input form format, save cursor position \n newline \t to generate horizontal Tab \v to generate vertical TabCopy the code