The Linux command Note LS

Source: Internet
Author: User

If you want to show all the commands in a continuous update to a blog, it will be very inconvenient to find in the future. For this reason, many of the commands are recorded separately in the future.
Here, some basic usage is not too much to explain. The main record is usually used in some of the commands.

Command: LS-[options] [operation Object]

    • Reverse the current directory information after entering the directory
使用参数d即可。eg: hicode@test:~/lab/dir$ ls1.md  2.md  3.md  4.md  5.md  6.md想反查看dir目录的信息hicode@test:~/lab/dir$ 34096Jul  101:17 .
    • List all sub-directories in the current directory only

No direct command, use grep to filter, flag isls 加上 -p后会给目录文件加上/符号

-p,–indicator-style=slash
Append/indicator to Directories

Eg:[email protected]:~$ ls-lp |Grep/Drwxr-XR- x 3Hicode Hicode4096Dec -   -Desktop/Drwxr-XR- x 2Hicode Hicode4096Nov7   -Documents/Drwxr-XR- x 2Hicode Hicode4096Dec -   -Downloads/Drwxrwxr- x 7Hicode Hicode4096Dec9   -Gothonweb/Drwxrwxr- x 3Hicode Hicode4096Jul1  on: theLab/Drwxrwxr- x 4Hicode Hicode4096Dec -   -Labs/

Another method is ls -l to display the records in which the directories are to d begin with.

-l |grep ^d
    • List files only

can be writtenls -lp | grep [^/]$

Principle: Lists all outputs that do not end with the output / from thels -lp

[Email protected]:~$ ls-lhpa |grep ' [^/]$ ' Total 1.2g-rw------- 1 hicode hicode K Jul1 xx:49 . Bash_history  -rw-r--r-- 1 hicode hicode  7 . Bash_logout    -rw-r--r-- 1 hicode hicode 3.5K Nov7 . BASHRC    -rw------- 1 hicode hicode M Dec  Core  -rw-r--r-- 1 hicode hicode  June  : DMRC -rw-r--r-- 1 hicode hicode 8.3K Nov7 examples.desktop     

Or use a different method: ls -l显示的文件都是以-开头作为文件标志 . So it can also be written, this good understanding.

[Email protected]:~$ ls- L |grep ^--RW------- 1Hicode Hicode33206272Dec -   -Core-RW- R--R-- 1Hicode Hicode8445Nov7   -Examples.Desktop-RW-RW- R-- 1Hicode Hicode279The1  2005Hosts-RW- R--R-- 1Hicode Hicode -June -  A: -Issue-RW-RW- R-- 1Hicode Hicode176June -  +: $Log1.Txt-RW-RW- R-- 1Hicode Hicode4617Jan A   theMans.Config
    • View the number of files in the current directory, append a pipeline command to the previous command |wc -l (Wordcount-linenumber)
Hicode@test:~$ Ls-l |grep ^-|wc-l (file) theHicode@test:~$ Ls-lp |grep ^d |wc-l (catalogue) +Hicode@test:~$ Ls-lp |wc-l (All) *                                    the+ +  noteq *( the.) Hicode@test:~$ Ls-lp |grep ^d |wc-l +Hicode@test:~$ Ls-lp |grep ^[^d] |wc-l -Hicode@test:~$ Ls-l |grep ^[^d-] (Soga, there is a row of statistics) total1166396There was another line.

lsThe directory tree structure cannot be displayed and can be downloaded tree .

sudo apt-get install tree

Usagetree --help

Very useful, and LS, the default is not the input path is the current directory

hicode@test:~/lab$ tree.├── a.txt├── b.txt├── c.txt├── dir│   1.md│   2.md│   3.md│   4.md│   5.md│   6.md│   └── sadf├── d.txt└── e.txt211 files

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The Linux command Note 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.