Several ignored options in the ls command

Source: Internet
Author: User
Article title: describes several ignored options in the ls command. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In Unix, the ls command can be used to list all Directory files, common files, and device files under the current directory or specified directory. Using this ls command with its rich options, it can complete some complex functions. Unfortunately, most users only know the basic usage of the ls command. Many options are useful, but they are ignored. I will take this opportunity to share with you several ignored options in the ls command.

 1. list all objects.

As shown in, execute ls and ls? What is the difference between the execution results of command a and the two? If the light is an ls command without the-a option, only one admin is displayed. With The-a command, more results are displayed. It can be seen that, without option-a, only some directory files or common files are displayed. From the above results, we can see that the hidden directory file or common file, and two indicate the current directory (.) and the parent directory (..) directory files are not displayed without the-a option. For system engineers, the main concern is the hidden files. Because sometimes system engineers need to edit these hidden files. Before editing or copying and moving, they must first determine whether the hidden file exists. So we have to use ls first? A command to view all the files, including hidden files. Then decide how to proceed.

It can also be seen from this that viewing hidden files in Unix operating systems is different from Windows operating systems. In Windows, you must select the "View all hidden files" option to view hidden files. If you want to hide these hidden files again next time, you need to remove this option. This operation is relatively troublesome. In the Unix operating system, you only need to add a-a option when you need to display it. There is also a slight difference between the two in display. In Windows, if the directory data is hidden, the hidden folder will have a faint watermark effect. You can clearly understand that this is a hidden folder. However, in a Unix operating system, no such stunt effect exists. Generally, in a Unix operating system, you can determine whether a directory file is a hidden file or whether a common file is a hidden file based on the file name. As shown in, if the file name starts with a dot in English, it indicates that this is a hidden directory file.

  2. display all directories and files recursively.

Although ls? A can display all files in the current directory. However, it can only display the directory files and common files in the current directory. The file in the subdirectory at the next level cannot be displayed. As shown in, admin and. kde are two subdirectories in the current directory. If you only use ls? Command a cannot list the file information of this sub-directory folder. However, sometimes you need to know all the file information in the current directory, including the file content in its subdirectory. For example, you need to delete a directory file that contains multi-level subdirectories, but it cannot ensure that all files in this directory are useless. Therefore, the system needs to display all the files and contents in a directory tree. It can clearly determine whether these files are still in use. If this requirement cannot be met, you have to use the cd command to enter the corresponding subdirectory, and then use the ls command to view it. If the number of levels of the directory is large or the number of subdirectories at the same level is large, this operation is obviously very troublesome. Therefore, users now like to be able to view all files and sub-directories in a directory tree at a time.

 

[1] [2] Next page

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.