web123456

Linux text operation instructions

  • cat:Used to view the contents of text files, or to merge multiple files.

    cat file name
    • 1
  • more and less:Used to view text files page by page, especially for large files.

    more file name
     less file name
    • 1
    • 2
  • head and tail:Used to display the beginning or end of a text file.

    head file name
     tail file name
    • 1
    • 2
  • grep:Used to search for specified string patterns in text files.

    grep "Mode" file name
    • 1
  • sed:Used to replace and edit text files.

    sed 's/old mode/new mode/g' file name
    • 1
  • awk:Used to process and analyze data from text files.

    awk 'condition { operation }' file name
    • 1
  • cut:Used to cut the specified field or character from each line of the text file.

    cut -d'delimiter' -f field number File name
    • 1
  • sort:Used to sort lines of text files.

    sort file name
    • 1
  • uniq:Used to remove duplicate lines in text files.

    uniq file name
    • 1
  • wc:Used to count the number of words, lines and characters in a text file.

    wc file name
    • 1
  • tr:Used for character conversion, can be used to replace characters in text files.

    tr 'old character' 'new character' < file name
    • 1
  • vim and nano:Text editor for creating and editing text files.

    vim file name
     nano file name
    • 1
    • 2