linux command - ls (list directory contents)

ls -  list directory contents

 

grammar:

ls (option) (parameters)

 

Options:

-a: shows all files and directories (ls the default file name or directory name is considered shadow possession, does not list "."); 
-A: "." show hidden files in addition to shadow and ".." beyond the list of all files; 
-C: multi-column display output. This is the default option; 
-F: Append files after each output type identifier specific meaning: "*" indicates a regular file with executable permissions, "/" indicates a directory, "@" symbolic link " | "indicates a command pipeline FIFO," = "represents sockets socket. When the file is an ordinary file, does not output any identifier; 
-b: non-character file output in backslash "" add character encoding mode output; 
-C: and "-LT-time" option is used in conjunction, in accordance with file state time to sort the output directory contents, sorting is based on field ctime inode file in. And "-l" option when used in conjunction with, the sort of sentence is time to change the status of the file; 
-d: Only directory name, without displaying the content list directory. Display symbolic link file itself, without displaying the directory listing it points; 
-f: effect of this parameter and specify the same parameters "aU", and turn off the effect of "lst" parameter; 
-i: Displays the file inode number ( inode). An index node represents a file; 
- File - of the type : with function "-F" option is the same, but does not display "*"; 
-k: to KB (kilobytes) show file size; 
the -l: to long format displays the contents list in the directory. From left to right output information includes a file name, file type, permissions mode, the last modified time of hard links, owner, group, file size and file, and the like; 
-m: with "," document number for each segment and the name of the directory;  
-n: the user identification code and group identification code alternate name;
-r: reverse order with the file name and output directory contents list; 
-s: display size files and directories, in units of blocks; 
-t: Sort by modification time of files and directories; 
-L: If you experience nature for the file or directory symbolic link, direct file or directory that lists the original link points; 
-R: recursive processing, all files and subdirectories in the specified directory treated together; 
--full- Time : complete list date and time; 
--color [= the WHEN]: using different colors to highlight a different type.

 

meaning some files under color of linux file (the default, you can modify the color CRT clients)
  Finally, talk about the meaning of some colors of linux file under the file (by default, you can modify the color CRT clients)
  Green ----> representatives executable files (green for pass means) Oh
  red ----> represents the compressed file
  dark blue ----> represents the directory
  blue -----> represents the linked files
  gray ----> on behalf of other Some file

 

For example:

Displays the current directory non-hidden files and directories: LS

 

Display the current directory listing of all files, including hidden files, including: LS -a

 

Display file inode (inode index inode) information: LS -i file1 file2

 

The level of output file list: LS -m

 

 Recently modified files appear at the top: LS -t

 

Display file recursively: LS -R & lt

 

Details of all files and directories listed in the / home / folder: LS -lR

 

 Set out in detail the contents of the current directory to the "t" at the beginning of the directory of all: LS -lt *

 

Calculate the number of files and directories in the current directory:ls -l * |grep "^-"|wc -l ---文件个数 

                ls -l * |grep "^d"|wc -l    ---目录个数
 
Ls lists the files in the absolute path: ls | sed "S # ^ # #` pwd` "
 
Lists the names of all files in the current working directory is a beginning, the more the more new row back, you can use the following command: LS -tr a *
 
List all files in the current directory (including hidden files) absolute path of the directory is not recursive: the Find $ PWD -maxdepth 1 | xargs LS -ld
 
 
 
 
 
 
 
reference:
 
 
 
 
 
 

 

Guess you like

Origin www.cnblogs.com/smart-lily/p/11290418.html