Basic Linux usage-display file content

Source: Internet
Author: User
Tags openldap
Basic Linux usage-display file content-general Linux technology-Linux technology and application information. For more information, see the following. 1. cat
Is to directly display the content of the file to the screen, the following operations:

[Root @ Linux ~] # Cat install. log
...
...
...
Install vnc-4.1.2-9. el5.i386
Install screen-4.0.3-1. el5.i386
Install scim-bridge-gtk-0.4.5-7. el5.i386
Install scim-tables-chinese-0.5.6-7. i386
Install mini-com-2.1-3. i386
Install Deployment_Guide-zh-CN-5.0.0-19. noarch
Install Deployment_Guide-zh-TW-5.0.0-19. noarch
Install scim-pinyin-0.5.91-15. el5.i386
Install scim-chewing-0.3.1-10. el5.i386
Install scim-chinese-standard-0.0.2-1. el5.i386
Install vim-X11-. 0.109-3. i386
Install gftp-. 0.18-3.2.2.i386
Install gtkspell-2.0.11-2.1.i386
Install openldap-clients-2.3.27-5. i386
Install nmap-. 11-1.1.i386
Install OpenIPMI-tools-2.0.6-5. el5.3.i386
Install dhcp-. 0.5-3. el5.i386
Install zsh-4.2.6-1. i386
Install xchat-. 6.6-8. el5.i386
Install fonts-chinese-3.02-9.6.el5.noarch
Install stardict-2.4.5-5. i386
Install system-config-bind-4.0.3-2. el5.noarch

The preceding content is relatively large. "omitted. We only see the part after this file. It can be seen that this command is suitable for displaying less content than the maximum number of lines displayed on the screen.

This command also has the opposite method of tac. What do you want to display?

2. more
The cat command can only view part of the file or only a small file. To solve this problem more, perform the following operations:

[Root @ Linux ~] # More install. log
Install libgcc-4.1.1-52. el5.i386
Warning: libgcc-4.1.1-52.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Install setup-2.5.58-1. el5.noarch
Install filesystem-2.4.0-1. i386
Install basesystem-8.0-5.1.1.noarch
Install tzdata-2006m-2.fc6.noarch
Install glibc-common-2.5-12. i386
Install glibc-2.5-12. i686
Install glib2-2.12.3-2. fc6.i386
Install zlib-1.2.3-3. i386
Install chkconfig-1.3.30.1-1. i386
Install atk-1.12.2-1. fc6.i386
Install popt-1.10.2-37. el5.i386
Install libICE-1.0.1-2.1.i386
Install libSM-1.0.1-3.1.i386
Install libstdc ++-4.1.1-52. el5.i386
Install libart_lgpl-2.3.17-4. i386
Install mktemp-3:1. 5-23.2.2.i386
Install audit-libs-1.3.1-1. el5.i386
Install libusb-0.1.12-5.1.i386
Install bzip2-libs-1.0.3-3. i386
Install libpng-. 2.10-7. i386
Install libattr-2.4.32-1.1.i386
-- More -- (2%)

Note that a prompt is displayed at the bottom, indicating that only 2% of the file is displayed. Press the Space key to go over the next page. When the content is displayed, the system automatically exits, you can also press the "Q" key to exit.

3. less
More can display relatively large files, but it also has a disadvantage that it cannot flip pages up. To view the content again, you must re-run the command. Less solves the problem of the more command. Follow these steps:

[Root @ Linux ~] # Less install. log
Install libgcc-4.1.1-52. el5.i386
Warning: libgcc-4.1.1-52.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Install setup-2.5.58-1. el5.noarch
Install filesystem-2.4.0-1. i386
Install basesystem-8.0-5.1.1.noarch
Install tzdata-2006m-2.fc6.noarch
Install glibc-common-2.5-12. i386
Install glibc-2.5-12. i686
Install glib2-2.12.3-2. fc6.i386
Install zlib-1.2.3-3. i386
Install chkconfig-1.3.30.1-1. i386
Install atk-1.12.2-1. fc6.i386
Install popt-1.10.2-37. el5.i386
Install libICE-1.0.1-2.1.i386
Install libSM-1.0.1-3.1.i386
Install libstdc ++-4.1.1-52. el5.i386
Install libart_lgpl-2.3.17-4. i386
Install mktemp-3:1. 5-23.2.2.i386
Install audit-libs-1.3.1-1. el5.i386
Install libusb-0.1.12-5.1.i386
Install bzip2-libs-1.0.3-3. i386
Install libpng-. 2.10-7. i386
Install libattr-2.4.32-1.1.i386
Install. log

The name of this file is shown at the bottom. We can use "PageUp" and "PageDown" to flip the previous and next pages. If you want to know the specific control key, you can press the "H" key to display all the control keys of the less command. If you want to end the operation, press the "Q" key.

4. head and tail
The above are the most commonly used commands for displaying file content. Here we also introduce two commands for displaying file content: head and tail, and head is the first few lines of the file, tail is the last few lines of the file. By default, it is 10 lines. Follow these steps:

[Root @ Linux ~] # Head install. log
Install libgcc-4.1.1-52. el5.i386
Warning: libgcc-4.1.1-52.el5: Header V3 DSA signature: NOKEY, key ID 37017186
Install setup-2.5.58-1. el5.noarch
Install filesystem-2.4.0-1. i386
Install basesystem-8.0-5.1.1.noarch
Install tzdata-2006m-2.fc6.noarch
Install glibc-common-2.5-12. i386
Install glibc-2.5-12. i686
Install glib2-2.12.3-2. fc6.i386
Install zlib-1.2.3-3. i386

[Root @ Linux ~] # Tail install. log
Install gtkspell-2.0.11-2.1.i386
Install openldap-clients-2.3.27-5. i386
Install nmap-. 11-1.1.i386
Install OpenIPMI-tools-2.0.6-5. el5.3.i386
Install dhcp-. 0.5-3. el5.i386
Install zsh-4.2.6-1. i386
Install xchat-. 6.6-8. el5.i386
Install fonts-chinese-3.02-9.6.el5.noarch
Install stardict-2.4.5-5. i386
Install system-config-bind-4.0.3-2. el5.noarch

The first 10 rows and the last 10 rows of the file are displayed respectively.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.