查看当前目录下文件的个数:
ls -l | grep "^-" | wc -l
查看当前目录下文件的个数,包括子目录里的:
ls -lR | grep "^-" | wc -l
查看当前目录下文件夹(目录)的个数,包括子目录里的:
ls -lR | grep "^-" | wc -l
其中:
ls : list directory contents
-l : use a long listing format
-R : --Recursive
list subdirectorys recursively
grep : print a lines matching a pattern
wc : print the numbers of bytes,words,and lines in files
-l : --lines
print the newline counts