Creating, Viewing, and Editing Text File



Topic : Creating, Viewing, and Editing Text File



Objective

in this session we have learn about Creating, Viewing, and Editing text file in different way on Linux Machine and user should get familiar with the Linux text Editor. in this session we have seen about different type of text editor in Linux.

Topics

  1. Editing Text File on Terminal.
  2. Editing Text File from shell Prompt.
  3. Editing Text File from Graphical editor.

1. Editing Text File on Terminal

Objectives

Describe the technical terms standard input, standard output, and standard error. redirect characters to control output files.

The Editing Text File from command are basically use to store the output of given command or errors of command. if required to store the output of command to used following option front of command to store required output or errors of command.

Output Redirection Operators

command >file_name
The standard output stream will be redirect store the generated output of command in file_name. it will not be visible in the terminal. if the given file is contain data already then it will be erase and store the only output are generated by command. basically it not support append Operation.

command >>file_name
The standard output stream will be redirect to store the generated output of command in file, append to current file content. it will not be visible in the terminal

command 2> file_name
The standard error stream will be redirect to store the error generated by the command in given file. it will not be visible in the terminal. if the given file is contain data already then it will be erase and store the only error are generated by command. basically it not support append Operation.

command 2>> file_name
The standard error stream will be redirect to store the output as well as error of the command.it will not be visible in the terminal.append to current file content.

command &> file_name
Both the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, it gets overwritten.

command &>> file_name 
Both the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.

command |& tee file_name
Both the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, it gets overwritten.

command |& tee file_name
Both the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, the new data will get appended to the end of the file.

2. Editing Text File from shell Prompt

Objective

in this session we have learn about the text editor which are mainly used in Linux. in the Linux system the mainly two editor are available VI and VIM editor. the both editor are developed by bill joy's. this editor are managed from terminal, and it's not provide in graphical mode. so in this session we have learn about how to use VIM editor.

Information about VIM editor

Open command line in VIM 
To open command line VIM editor is important because the all operation of VIM editor is performed using the command line. the esc key are used to open command line in VIM editor.
Open text file in vim editor to use simple command
vim <file_name>
root@batman:~# vim file1

Insert in VIM
To insert a text in given file use i keyword.
esc -> : -> i
first we open command line on VIM and then enter a Colon key and the i keyword is used.

Move around 
Use the cursor keys, and the following alphabet to perform move operation.
  • "h" this alphabetic keyword are used to move left operation.
  • "j" this alphabetical keyword are used to move down operation. 
  • "k" this alphabetical keyword are used to move up operation.
  • "l" this alphabetical keyword are used to move right operation.
                                   k
                             h          l
                                   j

Close this window
The close editor window follow following steps
  • esc (enter esc button)
  • : (enter colon key)
  • q (quit)
The quit option are used with different behaviour
: qw this command used in VIM editor to close window with save changes.
: qa! or :!q this command used in VIM editor to close window without saving changes.

jump to a subject
Position the cursor on tag (e.g. bars) and hit CTRL.

with the mouse
": set mouse=a" to enable the mouse (in xterm or GUI), Double-click the left mouse button on a tag, e.g. bars.

jump back
type CTRL-0. Repeat to go further back.

Get Specific help
it is possible to go directly to weather you want help on, by giving an argument to the :help command.
prepend something to specify the context: help-context
get more information about VIM editor to enter command on VIM editor
:help-context

3. Editing Text File from Graphical editor

in this session we have learn about the Graphical editor, previous session we have see the editor in command line interface. the Linux system is also provide graphical interface, mainly used gedit to edit text file.
gedit is a powerful general purpose text editor in Linux. It is the default text editor of the GNOME desktop environment. One of the neatest features of this program is that it supports tabs and graphical interface, so you can edit multiple files.
the view of gedit :-

gedit window view

Disclaimer :-
The above information is published by the codeworld19 authority using help of Linux terminal documentation if any query regarding this page or other issue regarding this website contact the codeworld19 authority from fill the following contact form, Thank you.




Next Post Previous Post
No Comment
Add Comment
comment url