
- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How to display the last part of the file in the Linux system?
To display the last part of the file, we use the tail command in the Linux system.
The tail command is used to display the end of a text file or piped data in the Linux operating system. By default, it displays the last 10 lines of its input to the standard output. It is also complementary of the head command.
Syntax
The general syntax of the tail command is as follow −
tail [OPTION]... [FILE]...
Brief description of options available in the tail command.
Sr.No. | Option & Description |
---|---|
1 | -c, --byte = [-]NUM Display the last NUM bytes of each file. Or -c +NUM to display starting with byte NUM of each file. |
2 | -f, --follow [ = {name | descriptor}] Display appended data as the file grows. |
3 | -F Same as --follow =name --retry |
4 | -n, --lines [-]NUM Display the last NUM lines instead of the first 10. |
5 | --max-unchanged-starts = N With --follow = name, reopen a FILE which has not |
6 | --pid = PID With -f option, terminate after process ID, PID dies |
7 | -q, --quiet, --silent Never prompt headers giving file names |
8 | --retry Keep trying to open a file if it is not accessible |
9 | -v, --verbose Always display headers giving file names |
10 | -z, --zero-terminated Line delimiter is NULL, not newline |
11 | --help Displays a help message and then exits. |
12 | --version It gives info about the version and then exits. |
By default, the tail command prints the last ten lines without any option as shown in this example.
First, we will create a file containing more than ten lines using the cat command in the Linux system as shown below.
$ cat >text.txt First line... Second line...Third line... Fourth line... Fifth line... Sixth line... Seventh line... Eighth line... Ninth line... Tenth line... Eleventh line...
Then, we will use the tail command in the Linux system to display the last ten lines.
$ head text.txt Second line... Third line... Fourth line... Fifth line... Sixth line... Seventh line... Eighth line... Ninth line... Tenth line... Eleventh line...
To prints the last n lines, we use -n or --lines option with the head command as shown below.
Suppose we want to display the last four lines of the text.txt file then we have to execute the command as shown below.
$ head -n 4 text.txt
To check more information about the tail command, we use the --help option with the head command in the Linux operating system as shown below.
$ tail --help
To check version information of the tail command, we use the --version option with the tail command in the Linux operating system as shown below.
$ tail --version
- Related Articles
- How to display the first part of the file in the Linux system?
- Remove the Last N Lines of a File in Linux
- How to flushes file system buffers in the Linux operating system?
- How to display the current working directory in the Linux system?
- How to format contents of a text file in the Linux system?
- How to Create a File in the Linux/Unix system using terminal?
- Delete the History of the Last n Commands on Linux
- How to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)?
- How to remove sections from each line of files in the Linux system?\n
- How to remove files and directories in the Linux operating system using the terminal?\n
- How to Create a New Ext4 File System in Linux?
- Display specific columns of a file in Linux?
- How to merge lines of files in the Linux system?
- How to move jobs to the background in the Linux system?
- How to list all users who are currently logged into the Linux system?\n
