Skip to main content

Posts

Showing posts with the label Less command

Viewing files with line numbers in Linux terminal

 Reading files is basic and a must when working on the terminal in Linux or command line. There are a lot of ways to do this, a simple task but quite a few ways to accomplish it. Nano, vi/vim the most common editor in Linux that is part of the package in most Linux flavors if not all. In nano editor, while the file is open pressing "alt + n", will display the line numbering on the left side of the screen. Example image: In vi or vim, opening the file and typing the command: "set nu" or "set number" will also view the lines on the left side of the screen. Example image:   Or from the command line itself using "cat -n any_file_name.txt" will also view line numbers the -n is a parameter on cat to view or include the line numbers when displaying the file. Example image: less -N, command will also produce same result. Or just use nl , "man nl" shows:  NAME        nl - number lines of files It comes pre-installed in almost any Linux flavors,...