The linux command file filtering magical

Source: Internet
Author: User


when we just want to show the folder, it can often ....

first of all, there has to be such a environment.

The first way (using grep command to filter ):

command:ls-l|grep D

command:ls-lf|grep/$

The second way (using awk command to filter ):

command:Ls-l|awk '/d/{print $} '

command:Ls-l|awk/^d/

command:Ls-l|awk '/d/{print $NF} '

The Third Way (using sed command to filter ):

command: ls-l|sed-n '/d/p '

Fourth Way ( filter by using the Find command)

command : find/wuxb/day1/-type D

Find Common parameters:

-type Find a file of a certain type: for example:

B- block device files

D- Catalog

C- character device files

P- Piping file

| - Symbolic Link file

F- normal file

-name finding files by file name

The-exec find command executes the shell command given by the parameter to the matching file . The corresponding command is in the form of 'command{} \; ' Note The space between {} and / ;


File filtering for Linux commands magical

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.