I am a windows user and never tried to use Linux before this job .But my work involves Linux and most of the time i need to work in Linux shell prompt not GUI. As every new user of Linux shell uses vi editor i also started with it and below are the commands i learned , which i felt its worth sharing,
vi madhu - Opens a file
ESC + : + wq - saves the file and exit
ESC + : + q - Exits the file without saving the changes
ESC + : + w! - Saves the changes without exiting the file
ESC + : + $ - Moves the cursor to the last line of the file
ESC + : + 1 - Moves the cursor to the first line of the file
ESC + :set nonu - Removes the line number in the file
ESC + :set nu - Displays the line number in the file
ESC + /madhu - Searches for the string 'madhu' in tht file
ESC + :3 - Go to the 3 line
ESC + :w /tmp/newfile - Writes the contents of the current file to
'/tmp/newfile'
ESC +:1,10w /tmp/newfile - Writes the contents of line 1 to 10 to the
'/tmp/newfile'
ESC + :w! /tmp/newfile - Overwrites the file '/tmp/newfile' with this file's
content
Remember there are other text editors in Linux like Emacs, vim . I preferred vi as i felt it was easy to use.
No comments:
Post a Comment