50 likes | 52 Views
UNIX/LINUX COMMANDS VISUAL EDITOR Creating & Editing files using vi $vi filename ` Starts at line 1 $vi +n filename Starts at line n $vi + filename Starts at last line
E N D
UNIX/LINUX COMMANDS VISUAL EDITORCreating & Editing files using vi $vi filename ` Starts at line 1 $vi +n filename Starts at line n $vi + filename Starts at last line $vi +/pattern filename Starts at ’pattern’ $vi –r filename Ġ! Recovers file after a system crash Cursor Movement h -- Moves the cursor to the left (Moves one space left) j -- Moves the cursor to the next line, same column ( Moves one line down) k -- Moves the cursor to the preceeding line, same column ( Moves one line up) l -- Moves the cursor to the right ( Moves one space right) <space> -- Moves the cursor to the right ( Moves one space right) w -- Moves the cursor a word forward (Moves 1 word right) b -- Moves the cursor a word backward (Moves 1 word left) b -- Moves the cursor a word backward (Moves 1 word left) $ -- Moves the cursor to the last character of a line 0 -- Moves the cursor to the first character of a line <enter> -- Moves the cursor to the next line ( -- Moves to the beginning of the sentence ) -- Moves to the end of the sentence { -- Moves to the beginning of paragraph } -- Moves to the end of paragraph <control>u -- scrolls up ½ screen <control>d -- scrolls down ½ screen <control>b -- scrolls up one screen <control>f -- scrolls down one screen
DELETEINPUT x --delete character a --append after cursor nx --delete n charaters A --append at end of line X --delete character before cursor i --insert before cursor dd --delete line I --insert before first non-blank ndd --delete n lines o --open and insert at line below D --delete rest of line O --open and insert at line above dw -- deletes a word dO -- deletes to beginning of a line d$ -- deletes to end of a line 3dw -- deletes 3 words 5dd -- deletes 5 lines
MODIFYINGEXIT AND SAVE FILES r --replaces the current character ZZ -- Exit (save & quit) R --replaces until Esc :q! -- quit vi without saving changes s --substitute text for character :wq -- write(save) & quit until Esc. w - writes (save)out the file without quitting vi cw -- Changes 1 word :x -- writes the file, quits vi 3cw -- Changes 3 words c -- Changes current line 5cc -- Changes 5 lines BLOCKING COMMANDS :nd -- Deletes nth line :m,n d -- Deletes lines from m to n :n mo p -- Move line n after line p :m,n mo p -- Move lines m to n after line p :m co p -- Copies line m after line p :m,n co p -- Copies lines m to n after line p :m,n w filename -- Writes lines m to n to a file :m,n w >> filename -- Appends lines m to n to a file :r filename -- Reads the contents of the file filename at the current cursor position
TO COMPILE A PROGRAM FILE TO EXECUTE A FILE $cc filename.c -lm ( Executable file is stored as a.out) $a.out ( Execute a file) TO COMPILE & OBJECT FILE STORED INTO SPECIFIED FILE $cc -o filename.out filename.c –lm ex: $cc -o anil.out anil.c –lm TO EXECUTE A FILE $filename.out ex: $anil.out SPECIAL COMMANDS > -- Redirecting the output to a file < -- Redirecting the input to a file Ex : anil.out<data1>output1 Name of the input file is data1 and name of the output file is ouput1 anil.out<anilin1> anilout1 >> -- Appending a (ouput) file. Ex: $ file1>>file2 file1 is appended to file2 u -- undoes the last command U -- restores the current line to its state before you changed it J -- joins the line immediately below the current line with the current line :n -- cursor move to 'n'th line yy -- Marks the current line p -- Puts the marked text in new position
$ ls Lifts the files/directories $ ls | pg Lifts the files/directories page by page $ pwd Print working directory (Present working directory) $ mkdir To create a new directory $ rmdir Removes directory $ cd To change directory $ ls-cf List files and directories columnwise $ cp anil.c pavan.c Duplication of file with another name $ cp anil.c/temp/anil.c Copies anil.c from current directory to temp directory $ mv file1 file2 Name of file1 is changed to file2 $ rm file1 file2 file3 … Removes the files file1, file2, file3 ….. Press “Delete” key to stop running a program