Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-02 00:29:37 09月28日 Update

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.

Tags: File directory representative search command structure path key keyword more knowledge article red link utility generality code that is work meeting meaning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Redmi Docker MySQL Huawei