Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Shell to write a command that displays the directory structure

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What this article shares to you is about how to use Shell to write a command to display the directory structure, the editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Don't say much, follow the editor to have a look.

Use Shell in Linux to write a command that displays the directory structure to quickly find the directory structure.

1. Code

#! / usr/bin/env bash# this command is used to display the specified path or the current path file structure, support search # tf displays the current directory file structure # tf followed by keyword search current directory # tf directory keyword search specified directory # this command depends on the tree command DIR=KEYWORD=# does not pass the path default is to search if [#-eq 1] Then KEYWORD=1fi# specifies a path to search if [#-eq 2]; then DIR=1 KEYWORD=2fiif [- n "DIR"]; then cd "DIR" | | exit 1fipwdtree-C-f | grep "KEYWORD"

2. Use effect

Current path

Tf

Search

Tf keywords / / such as tf lib

Specify a path to search for

Tf / usr/local/ lib

3. Color meaning

Blue represents the catalogue

Green represents executable file

Red represents a compressed file

Light blue represents the linked file

Gray represents other documents.

Flashing red indicates that there is a problem with the linked file

Yellow represents the device file

White represents general documents, such as text files, configuration files, source files, etc.

The above is how to use Shell to write a command that displays the directory structure. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report