Linux,如何使用目录名创建文件?

标签 linux directory

如何创建文件夹,例如:wdw/1/11、wdw/2/22、... wdw/6/66、...、wdw/9/99,以及使用最深目录中的目录名创建文件,例如目录名_文件.txt

最佳答案

在 bash 中:

mkdir wdw                                    # Creates the top dir.
mkdir {1..9}                                 # Creates the subdirs using brace expansion.
for dir in {1..9} ; do
    mkdir $dir/$dir$dir                      # Creates the subsubdirs.
    touch $dir/$dir$dir/$dirdir"_file".txt   # Creates the file.
done

关于Linux,如何使用目录名创建文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13181034/

相关文章:

linux - 抑制或防止重复的 inotifywait 事件?

c# - 如何在 C# 中列出 .zip 文件夹的内容?

gnuplot - 在 Gnuplot 中创建一个输出目录

python - 删除 Python 中除最新文件夹外的所有文件夹

c - 信号量相关 - smtctl 使用 IPC_RMID 失败,参数无效

linux -/usr/bin/ld : cannot find -lglut

android - Android平台下如何删除SD卡中的文件/文件夹?

networking - 检查文件夹是.NET中的本地资源还是网络资源

linux - 当用户想要关闭它时从 bash 脚本的 STDIN 退出

linux - vm.dirty_ratio 和 vm.dirty_background_ratio 之间的区别?