[英]shell scripting : I have a main directory which contain few other directories and I want to print all files inside those directories
This script only print files from main directory but doesn't print files of an sub directory that is present in main directory.此脚本仅打印主目录中的文件,但不打印主目录中存在的子目录的文件。
If not clear what I mean is if I have a main directory and that main directory has 5 sub directories and all of them contains file.如果不清楚我的意思是如果我有一个主目录并且该主目录有 5 个子目录并且它们都包含文件。 I just want to print all of those files.
我只想打印所有这些文件。
read filename
for entry in "$filename"/*
do
echo "$entry"
done
I just want to print all of those files.
我只想打印所有这些文件。
Then use find
.然后使用
find
。
find "$filename" -type f
will print all filenames.将打印所有文件名。
I have to ask: which shell?不得不问:shell是哪个? a Linux shell?
Linux shell? Powershell?
Powershell?
If Powershell:如果 Powershell:
$files = Get-Childitem -Recurse
Just don't use this starting at just the C:\
.只是不要从
C:\
开始使用它。
But with your read
and echo
, it looks like Linux.但是通过您的
read
和echo
,它看起来像 Linux。 have you tried the tree
command?你试过
tree
命令吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.