Viewing contents of file




















The usual way to view the contents of a file is to simply open it in a text editor. However, for more quick viewing and in fact, also for automating in a shell script, the method of using a text editor does not suit. There are many commands in Linux to solve this problem: to display the file contents on the command line. A cat command is the most commonly used command to view the contents of a file.

The syntax to use cat is quite simple, as shown below:. The nl is another command in Linux which displays the contents of a file. The nl command has even more options to format the output numbering in various ways.

However, to simply display the contents, it can be used as discussed above. There are different tools and commands if you want to read binary files. Cat simply prints the content of the file to standard display i. It cannot be simpler than this, can it? Cat becomes a powerful command when used with its options. I recommend reading this detailed tutorial on using cat command. The problem with cat command is that it displays the text on the screen.

Imagine if you use cat command with a file that has lines. So, what do you do in such a case? Use less command in Linux explained later. The nl command is almost like the cat command. The only difference is that it prepends line numbers while displaying the text in the terminal. There are a few options with nl command that allows you to control the numbering. You can check its man page for more details.

Less command views the file one page at a time. The best thing is that you exit less by pressing q , there are no lines displayed on the screen. Your terminal remains clean and pristine. I strongly recommend learning a few options of the Less command so that you can use it more effectively. There is also more command which was used in olden days but less command has more friendly features.

This is why you might come across the humorous term 'less is more'. Head command is another way of viewing text file but with a slight difference. The head command displays the first 10 lines of a text file by default. You can change this behavior by using options with head command but the fundamental principle remains the same: head command starts operating from the head beginning of the file.

Installation Get this app while signed in to your Microsoft account and install on up to ten Windows 10 devices. Accessibility The product developer believes this product meets accessibility requirements, making it easier for everyone to use.

Language supported English United States. Seizure warnings Photosensitive seizure warning. Report this product Report this app to Microsoft Thanks for reporting your concern. Our team will review it and, if necessary, take action.

Sign in to report this app to Microsoft. Report this app to Microsoft. Report this app to Microsoft Potential violation Offensive content Child exploitation Malware or virus Privacy concerns Misleading app Poor performance.

How you found the violation and any other useful info. Submit Cancel. System Requirements Minimum Your device must meet all minimum requirements to open this product OS Windows 10 version Recommended Your device should meet these requirements for the best experience OS Windows 10 version Open in new tab.



0コメント

  • 1000 / 1000