Tagged with: ls wildcard
Command function
Usage
Parameters
Other extensions
Practice
Command function
LS: Lists all subdirectories and files in the target directory.
Usage
ls [options] [directory name]
Parameters
-a,–all Lists all files under the directory, including the. The implied file at the beginning
-a with-A, but does not list "." (represents the current directory) and ".." (Represents the parent directory of the current directory). -c mate -lt: Based on ctime sorting and display ctime (time of last change of file status) Mate -l: Display ctime But sort by name otherwise: According to ctime sort-c Each column is listed from top to bottom –color[=when] controls whether to use color-resolved files. when can be ' never ', ' always ' or ' auto ' one of them-d, –directory displays the directory as if it were a file, rather than displaying the file under it. -d, –dired results for Emacs dired mode use-f the output file is not sorted,-au the option takes effect,-LST The option fails-g similar to -l, but the owner-g, –no-group does not list any information about the group-h, –human-readable List file sizes in an easy-to-understand format (for example, 1k 234m 2g) –si similar to -h, but the size of the file takes 1000 the second side instead of 1024-h , –dereference-command-line Use the symbolic link in the command column to indicate the true destination –indicator-style= way Specify that the indicator is added after each project name < way > :none (default),classify (-F),file-type (-p)-i, –inode print out the inode number of each file-i, – Ignore= style Do not print any items that conform to shell character < style >-k that is –block-size=1k, to k The size of the file is represented as a byte. -l In addition to the file name, the permissions, owner, fileSize and other information are listed in detail. -l, –dereference when displaying the file information for a symbolic link, the information indicated by the symbolic link is displayed instead of the symbolic link itself-m all items are separated by commas and fill the entire row width-o like -l. Displays details of the file in addition to the group information. -r, –reverse in reverse order-r, –recursive lists all subdirectory tiers at the same time-s, –size List the size of all files in block size-s Sort by file size –sort=word The following are the optional WORD and the corresponding options they represent:extension -x status -cnone -u time -tsize -s atime -utime -t access - uversion -v use -u-t Sorting by file modification time-u mate -lt: Show access time and sort mate -l by access time: Show access time but sort by name otherwise: Sort by access time-u not sorted; Lists items-v according to the original order of the file system-w, –width=cols Specify the screen width yourself instead of using the current value-x list items line by row instead of columns-x sort by extension -1 only one file per line –help show this help and leave –version Show version information and leave
Other extensions
Wildcard: A wildcard is a special statement used to blur a search file.
* Match 0 or more characters? match any single character ~ Current user home directory ~username user home directory ~+ current working directory ~-previous working directory [WXC] matches any of the characters in the list [^WXC] matches all characters in the list predefined character classes: #man 7 glob[:d Igit:]: Any number, equivalent to 0-9[:lower:]: Any lowercase letter [: Upper:]: Any capital letter [: Alpha:]: Any uppercase and lowercase letter [: alnum:]: Any number or letter [: space:]: space [:p UNCT :]: Punctuation
Practice
ls-d. *
ls-d * *
[Email protected] var]# ls-dl*[[:d igit:]][[:lower:]]l111s[[email protected] var]#
[[email protected] etc]# ls-d [[:d igit:]]*[^[:d igit:]]1da 1.ddd[[email protected] etc]#
[Email protected] etc]# ls-d[^[:alpha:]]*[[:alpha:]]1da 1.ddd 1www[[email protected] etc]#
[Email protected] etc]# ls-d m*[^[:d igit:]]magic makedev.d mime.types motd my.cnfmailcap man.config mke2fs . conf mtabmail.rc maven MODPROBE.D mtools.conf
[[email protected] etc]# ls -d *.dbash_completion.d modprobe.d rc.dchkconfig.d oddjobd.conf.d reader.conf.dcron.d pam.d request-key.ddepmod.d popt.d rsyslog.ddnsmasq.d prelink.conf.d rwtab.ddracut.conf.d profile.d sane.dggz.modules.d rc0.d setuptool.dinit.d rc1.d statetab.dlatrace.d rc2.d sudoers.dld.so.conf.d rc3.d sysctl.dlogrotate.d rc4.d xinetd.dlsb-release.d rc5.d yum.repos.dmakedev.d rc6.d
Displays files or directories with the . conf ending with the/ etc directory and beginning with m,n,r,p
[Email protected] etc]# ls-d [m,p,r,p]*.confmke2fs.conf readahead.confmtools.conf re ader.confpbm2ppa.conf request-key.confpm-utils-hd-apm-restore.conf resolv.confpnm2ppa.conf Rsyslog.confprelink.conf
ls command (contains wildcard characters) note