Linux command 1--ls

Source: Internet
Author: User
Tags echo b

LS is the abbreviation of the list to see the file information under the folder, here are a few common examples.

1 sorts all the files under the folder according to CTime (the last time the file was changed).

Ls-lct

2 Show All files,-G does not show the owner of the file,-O does not show the group of owners

Ls-g Ls-o

3 Display the file size in human-read form

Ls-lh

4 Display the file as a comma-delimited line

Ls-m

5 Show All Files under folder

Ls-r

6 Ls-s Sort by file size ls-x sorted by file name extension

7 Ls-f can be appended to the list of files with a symbol, "*" for the executable of ordinary files; "/" for directories; "@" for symbolic links; "|" Represents FIFOs; "=" means socket

The following command indicates that subfolders are found in the folder

Ls-f | grep/$

Or use the following methods

Ls-l | grep ^d

8 Calculating the number of folders and files in a folder

Ls-l *

Used to calculate all files and folders in the current folder level directory

LS-LR *

Used to calculate all files and subdirectories under a directory

Ls-l * | grep ^-| Wc-l

Used to calculate all folders under a directory for all files and subdirectories

Ls-l * | grep ^d | Wc-l

Note here that the result of the WC display corresponds to the-L line number-m character number-C byte number, if the number of characters with the parameter-m, the number of words to calculate the parameter-W

9 absolute path for all files under the output folder

echo b |sed "s/^/' echo a '/"

Seb S represents a replacement, the above operation means to execute output B and append output A to the previous operation

where/can replace with alternative rich

echo b |sed "s:^: ' pwd '/:"

Represents an operation that performs a PWD plus "/" before performing an operation on output b

ls | Sed "s:^: ' pwd '/:"

Indicates the absolute path of all files under the list folder

10 lists the absolute paths of all files in the current directory, and subdirectories do not recursively

Find $PWD

$PWD represents the current directory string, find $pwd represents a lookup in the current directory

Find $PWD-maxdepth 1

-maxdepth means that only one layer is recursive

Find $PWD-maxdepth 1 | Xargs Ls-ld

Where Xargs is used to receive the preceding arguments.

Reference Document: Http://www.cnblogs.com/peida/archive/2012/10/23/2734829.html


Linux command 1--ls

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.