[英]Creating .finished file with the folder names under a directory
I've seen example of it as batch command but it is not working for me. 我已经看到了将其作为批处理命令的示例,但它对我不起作用。
I searched and there is a command like this : 我搜索了,有一个这样的命令:
find . -maxdepth 1 -type d
but it puts ./
to every folder name, is there a command that will give just folder names or how can i delete the first ./
characters in my script ? 但是它将
./
放在每个文件夹名称中,是否有一个仅给出文件夹名称的命令,或者如何删除脚本中的第一个./
字符?
After that i will read them line by line and create the .finished
files with touch commands. 之后,我将逐行阅读它们并使用touch命令创建
.finished
文件。
Any help would be approciated. 任何帮助将不胜感激。
Thanks a lot! 非常感谢!
find . -maxdepth 1 -type d -printf "%P\n"
使用sed
消除前两个字符,如下所示:
find . -maxdepth 1 -type d | sed 's?^[.]/??'
Try this, using cut
command we can discard ./
from the list of folder name. 尝试使用
cut
命令,我们可以从文件夹名称列表中丢弃./
。
find . -maxdepth 1 -type d|cut -c 3-
Or you can use this option too, suggested by @Luis 或者您也可以使用此选项,@ Luis建议
find . -maxdepth 1 -type d|sed -e 's:^\./::'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.