How to find subdirectories in Linux: 1. Log in to the Linux system, open and enter the terminal; 2. Get the file path by executing the "man ls" command; 3. Enter and execute "ls -R | grep. /" command can get all subdirectories in the current directory.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Linux Find out what subdirectories are there?
Find all subdirectories under the directory under LINUX
So we need to create the required file paths in advance.
The premise of this article is that the file path of the test environment already exists. This path does not exist in the new environment. At this time, you need to obtain the file path first.
When we use
man ls
ls -R
man grep
In fact, we only need to enter
ls -R | grep ./
find . -type f
Copy the above results and
replace
Replace "./" with " mkdir -p ./ "
Replace " : " with "; "
mkdir -p ./xxxx ;
Just execute all the above, or you can create a xx.sh file and enter the commands in it.
Execution
sh xx.sh;
The above statement first redirects to a certain file, for example:
">" is an overwrite redirection, so when redirecting, first check whether hello.sh exists, and it will be overwritten if it exists.
">>" is an additional direction
command parsing, the . here refers to all paths under the current path. Use / to get all directories under the root directory.
find . -type f > hello.sh;vi hello.sh;
:%s/\.\//mkdir -p /g :%s/$/;/g :wq
sh hello.sh;
The above is the detailed content of Find out what subdirectories are in linux. For more information, please follow other related articles on the PHP Chinese website!