Linux 124 Course 4, create, view, edit files

Source: Internet
Author: User

  • Redirecting output to a file or Grogram
          重定向

    > Chasing heavier orientation
    |&>> redirect both standard output and error output to a file
    | Pipe character (the output of the previous command as input to the next command)
    Tee is usually used in conjunction with pipe character, as the next command input colleague, do standard output

  • Whatis Cal

    Cal-1 cal-3 cal-y

    Cal > Cal.txt redirect standard output to Cal.txt
    Cat Cal.txt

    The call >cal.txt outputs the error output to the display
    Call 2>cal.txt error output, redirect to Cat.txt
    Each time a redirected output is made, the original content is overwritten

    Cal >>cal.txt
    Cal >>cal.txt
    Cal >>cal.txt

    Date >>test.file
    Cal 1&2>>cal.txt

    Call 2>/dev/null Discard the wrong information

    cat/etc/passwd
    cat/etc/passwd | grep root from the result of the previous command output, as input to the next command
    grep root/etc/passwd

    Ls-l |tee test.txt Output The command from the screen while importing into the file

    Ls-l | tee/dev/pts/0 |mail-s XXX

      1. Editor
        Vim
        Gedit Editor

    (1) Gedit test.txt editing tools for graphical editing tools

    (2) Vim non-graphical editing tools
    Vim has four basic modes:
    Command mode.
    Edit mode command line mode input I/O/A press ESC to return to command line mode
    Extend Command mode Input ":" Press ESC to return to command line mode.
    Visual edit mode Visual editing modes Press V/v/ctrl+v to enter

    command-line Mode commands
    G quickly position the cursor to the last line
    GG position the cursor to the first row
    5G position the cursor to line fifth
    o Insert row on the next line of the cursor
    O insert a row on the previous line of the cursor
    DD deletes the cursor in the row
    5DD Delete the five lines where the cursor is located
    d^ Delete the bank's contents before the cursor
    d$ Delete the contents after the cursor
    D Delete the contents after the cursor
    U undo
    U withdraw the contents of the bank
    YY copy
    5yy Copy Five Elements
    P Paste before cursor
    P paste on top of the line where the cursor is located
    H the top line of this page
    M in the middle of this page
    L the bottom line of this page
    /student down find keyword n toggle keyword n up toggle keyword
    Student Search up keyword n toggle keyword n Toggle keyword up

    Command for the last-line mode:
    : Nohl Suppress highlighting
    : Set Nu Sets line number
    : Set Nonu Cancel line number
    : W Save
    : Q exit
    : Wq Save and exit
    : wq! Force Save and exit
    : W/tmp/aa Save As
    : e/root/passwd Discard current file edit, open new file
    :! + command to execute commands without interrupting the current edits
    :! Date

    : R + File path reads other file contents at cursor location and inserts
    : r/root/cal

    : S/student/chen The first student replacement of the line where the cursor is positioned is called Chen
    S/student/chen/g: The student substitution of the line where the cursor is positioned is called Chen
    :%s/student/chen/g The student replacement of the full text called Chen
    :%S/STUDENT/CHEN/GC The student replacement of the full text, called Chen, for interactive substitution
    : 40,50 s/student/chen/g to replace 40-50 of student with the name Chen

    : SP Split window can be toggled by Ctrl+w window
    : VSP Vertical Split window
    CTRL +W Switch between windows
    Close window

    Visual editing mode:

    V Select text by character Delete delete
    V Select text on a per-end basis
    CTRL + V selects text as a chunk
      
      

    Linux 124 Course 4, create, view, edit files

    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.