Basic Linux Command Line to Read a File – Part 2

Command Line to Read File

0 65

SimpleSysAdmin.info. This article is the sequel from the previous article by title Basic Linux Command Line to Read a File – Part 1.

Here the rest of linux command line to read a file

5. less

Less – opposite of more. Less is a program similar to more, but which allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi. Less uses termcap (or terminfo on some systems), so it can run on a variety of terminals. There is even limited support for hardcopy terminals.

Read Using AI on the Play Store, Google wants to hide crashing Android apps

 

The syntax :

less -? or less –help
less -V or less –version
less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,…] [-y lines] [-[z] lines]
[-# shift] [+[+]cmd] [–] [filename]…

example :

less /var/log/message
less /var/log/message

Press the [Space] bar to go down one page, the [B] to go back one page, the directional (or “arrow”) keys to move one line at a time, and [Q] to quit. To search the output of a text file using less, press [/] and enter the keyword to search for within the file.

 

6. vi and vim

Vi – screen-oriented (visual) display editor and vim  – Vi IMproved, a programmers text editor. Vim is a text editor that is upwards compatible to Vi.  It can be used to edit all kinds of plain text,  especially editing programs. There are a lot of enhancements above Vi: multi level undo, multi windows and buffers, syntax highlighting, command  line  editing, filename  completion,  on-line help, visual selection, etc.

To edit a single file with the command

vim [filename]

More generally Vim is started with:

vim [options] [filelist]

If  the  filelist is missing, the editor will start with an empty buffer.  Otherwise exactly one out of the following four  may  be used to choose one or more files to be edited. Vim behaves differently, depending on the name of the command (the executable may still be the same file).

vim   

The “normal” way, everything is default.

ex

Start  in Ex mode.  Go to Normal mode with the “:vi” command. Can also be done with the “-e” argument.

view  

Start in read-only mode.  You will be protected from  writing  the files.  Can also be done with the “-R” argument.

gvim gview  

The GUI version.  Starts a new window.

gex

Starts  a  new  gvim window in Ex mode. Can also be done with the “-e” argument to gvim

vimx

Starts gvim in “Vi” mode similar to  “vim”,  but  with  additional features like xterm clipboard support

evim eview

The GUI version in easy mode.  Starts a new window.  Can also be done with the “-y” argument.

rvim rview rgvim rgview

Like the above, but with restrictions.  It will not be possible  to  start  shell  commands, or suspend Vim.  Can also be done with the “-Z” argument.

 

7. nano

nano – Nano’s ANOther editor, an enhanced free Pico clone. nano  is  a  small,  free and friendly editor which aims to replace Pico, the default editor included in the non-free Pine package.  Rather than just copying Pico’s look and feel, nano also implements some missing (or disabled by default) features in Pico, such as “search and replace” and “go to line and column number”.

 

ReadSetup Timezone and NTP on CentOS 6

 

The format of nano is

nano [OPTIONS] [[+LINE,COLUMN] FILE]…

If  no  alternative  spell checker command is specified on the command line or in one of the nanorc files, nano will check the SPELL environment variable for one.

In some cases nano will try to dump the buffer into an emergency file.  This will happen mainly if nano receives a SIGHUP or SIGTERM or runs out of  memory.   It will write the buffer into a file named nano.save if the buffer didn’t have a name already, or will add a “.save” suffix to the current filename.  If an emergency file with that name already exists in the current  directory,  it  will  add  “.save”  plus  a  number  (e.g. “.save.1”)  to  the  current filename in order to make it unique.  In multibuffer mode, nano will write all the open buffers to their respective emergency files.

 

Well, that was all linux command line that i used so far in my experience.

You might also like More from author