Linux Basic Command Line to Read a File – Part 1
Command Line to Read File
SimpleSysAdmin.info. If you wondering how to read a file in linux system, here some basic command line to read a file. Some of them default on linux or already installed, and some of the you should install first. You can use those command lines to view or read a file text or any other file such as doc, pdf and more.
Here the folowing command line to read or view a file:
cat is concatenate files and print on the standard output. cat command can read a text file with printing full content of the file to terminal screen.
The syntax :
cat [OPTION]… [FILE]…
head make output the first part of files.
The format of head :
head [OPTION]… [FILE]…
By default, you can only read the first ten lines of a file. You can change the number of lines displayed by specifying a number option
head -20 <filename>
tail make output the last part of files and tail is the reverse of head. Using tail, you can view the last ten lines of a file. This can be useful for viewing the last ten lines of a log file for important system messages.
tail syntax :
tail [OPTION]… [FILE]…
You can also use tail to watch log files as they are updated. Using the -f option, tail automatically prints new messages from an open file to the screen in real-time. For example, to actively watch /var/log/messages, enter the folowing at a shell prompt (as the root user):
Press [Ctrl]-[C] when you are finished.
more – file perusal filter for crt viewing and more is a filter for paging through text one screenful at a time.
more [options] file […]
the command is more /var/log/message
The [Space] bar moves forward one page and [Q] quits.
For the rest of command line to read to read file will be in Linux Command Line to Read a File – Part 2.