In Linux system, in addition to PHP can view the file directory, the shell command can also perform some operations on the file directory. Today, Xiaobian will share with you how to use the shell command to view the directory and its subdirectories. All files.
Use the shell command to view the files in the directory and all subdirectories method:
shell recursively traverse directories
#! /bin/bash
echo “please input the directory:”
read cdir
for dir in $(find $cdir -type d); do
echo change to $dir
cd $dir
ls
echo “----------”
done
cd $cdir
Record a script that traverses all subdirectories and their files under the directory today.
#! /bin/sh
read -p “Input Path:>SPATH
FILELIST() {
filelist=`ls $SPATH`
For filename in $filelist; do
if [ -f $filename ];then
echo File: $filename
elif [ -d $filename ];then
#echo Directory: $filename
cd $filename
SPATH=`pwd`
echo $SPATH
FILELIST
cd . .
else
echo “$SPATH/$filename is not a common file.”
fi
done
}
cd $SPATH
FILELIST
echo “Done.”
Implement traversal of directories and their subdirectories by defining a function.
Now Linux users know how to use the shell command to view all the files in the directory and its subdirectories. If you don't know the user, please refer to the above steps.
UDP is the permanent datagram protocol. It has the same function as the TCP protoco
Linux system operation, sometimes need to modify the environment variable PATH path
LAMP is a common environment for yum in CentOS6.5 system. The method of installing
Linux system operation, sometimes accidentally delete important files, and there ar
Unix uninstall gdb debugging tools trick
How to use cgroups to manage CPU resources under Linux
Notes on using the kill command in Linux
After the Linux boot, the terminal prompts -bash-2.05b$ What should I do?
How to deal with the database disappeared after modifying the root password of mysql under Linux?
Ubuntu shutdown can not shut down how to solve?
What should I do if the Linux system formats the partition and prompts Could not start /dev?
How to use Linux to use rsync command to delete small files in batches
Linux system using the sl command to make train dynamic desktop skills
Win7 registry repair exe file tutorial
How to update the computer system?
How to apply Win8 special effects theme in Win7 system
How does win8 change the status of the default browser of ie10?
How to disable Win8's hybridboot function in dual system so that it does not affect dual system
Win7 automatic update how to turn off the pop-up without its frequency
Mobile phone texting has been out. Try sending it with your computer
Windows 7 System Office Tips: Location-Aware Printing
Fast is efficient! Win7 uses multiple upgrades to improve the efficiency of the word