Home Exploring the 'more' command in Linux
Post
Cancel

Exploring the 'more' command in Linux

Intro

Introduction

The ‘more’ command in Linux is a simple but powerful tool for viewing the contents of a file one screen at a time. It is commonly used to display the contents of text files on the terminal. In this post, we will explore how to effectively use the ‘more’ command in Linux.

Basic Syntax

The basic syntax of the ‘more’ command is as follows:

1
more [options] [filename]

By simply typing ‘more’ followed by the name of the file you want to view, you can display its contents one screen at a time. Pressing the Space key will show the next page, while pressing Enter will show the next line.

Example Codes

Let’s look at some example codes to better understand how the ‘more’ command works:

  1. Display the entire contents of a file:
    1
    
    more filename.txt
    

    This command will display the contents of ‘filename.txt’ one screen at a time.

  2. Display the contents of a file with line numbers:
    1
    
    more -n filename.txt
    

    By using the ‘-n’ option, you can display line numbers alongside the contents of the file.

  3. Display the contents of a file with a specific number of lines per screen:
    1
    
    more -d -n4 filename.txt
    

    By using the ‘-d’ option followed by the ‘-n’ option and a number, you can set the number of lines to be displayed per screen.

Versions and Compatibility

The ‘more’ command is available on most Unix-like operating systems, including Linux and macOS. It is a standard command and should work on any Linux distribution. However, some versions of ‘more’ may have additional features or options.

Conclusion

In conclusion, the ‘more’ command in Linux is a handy tool for viewing the contents of text files. By understanding its basic syntax and options, you can efficiently navigate through files without overwhelming your terminal. Whether you need to quickly skim through a large file or just want to view its contents in an organized manner, the ‘more’ command is a versatile tool to have in your arsenal.

This post is licensed under CC BY 4.0 by the author.
Contents