Use the LS command to view a list of files and directories

Source: Internet
Author: User
Basic Features List ls The most basic form will display the current directory of files and directories

$ ls
Note that the list of the LS command output is sorted alphabetically (by column) -F parameter makes it easy to distinguish files and directories

$ ls-f
A forward slash (/) is added after the directory (folder) and the executable file is appended with * for easy user differentiation the-a parameter displays hidden files along with normal files and directories

$ ls-a
at the beginning of the point number are hidden files, and the file that starts with bash is the hidden scarf used by the bash shell Environment . The- r parameter, called the recursive option, lists the text in the subdirectory contained in the current directory, and if there are many directories, this output will be very long, and if there are more subdirectories, the-R parameter will continue to traverse

$ ls-r
⭐️tip: Parameters do not necessarily have to be separated, for example: Ls-f-R, you can ls-fr so to write ⭐️ Show long list the-l parameter can produce output in a long column table format. Contains more information about each file in the directory
$ ls-l

The first line of output shows the total number of blocks that are included in the table of contents. After that, each row contains a description file type for the file (or folder) , such as a directory (d), a file (-), a character file (c), a block device (b) file's permissions, such as read (R), write (W) Total number of hard connections to files file owner's username file the size of the group name file (in bytes) The file was last repaired the time file name or directory name filtered output list ls command also supports the definition of filters in the command. Use filters to determine which files and directories should be displayed in the output. You can do a simple text match, add this filter after the command argument

$ ls-l Test.txt

when the user specifies the filter, it displays information about the file and, of course, identifies the standard wildcard character for a fuzzy matching question mark (?). Represents a character asterisk number (*) representing 0 or more characters

$ ls-l te*
$ ls-l te*t
$ ls-l? est

using an asterisk or question mark in a filter is called a file extension match (globbing), which refers to the process of using wildcard characters for fuzzy matching, and the formal name of the wildcard character is called the wildcard character (metacharacter wildcards) In addition to the question mark of the asterisk, there are more metacharacters wildcard wildcards for file extension matches, you can use brackets, use brackets, and look for possible characters (E or S) at a particular location, for example: ls-l T[es]t.txt, can find Tet.txt and Tst.txt You can also specify a range ls-l t[a-i]st.txt You can also use an exclamation point to exclude unwanted content ls-l t[!b]st.txt. Create a file Touch creates an empty file in the current directory

Create a file named Test $ touch
test
if a file with that name is not present in the current directory, touch creates a file that, if it is present in the current directory, changes the file's modified time when the command is executed. But the contents of the file have not been changed.

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.