Рекурсивное создание каталогов и файлов с расширением bash

Я нашел комментарий к отчету об ошибке , и он мне помог (Драйвер KDE NEON + nvidia)

Crippling your system (switching to xrender and much slower nouveau driver) is not a solution.
What works for me flawlessly for more than a week on KDE Neon:
In file:
/lib/systemd/system/sddm.service
Add:
ExecStartPre=/bin/sleep 10
After [Service]
The problem apparently is that something SDDM needs is not initialized before is starts, so delaying SDDM by 10 sec is adequate workaround. Perhaps it could be less, but it doesn't bother me as long as I don't have to log out/log in manually.

2
31.12.2020, 15:57
2 ответа

Вы можете упростить первую mkdirдо одной команды, используя -pдля создания родительского каталога:

mkdir -p plans/2021-CW{01..52}

, а затем используйте только один touchдля создания файлов во всех каталогах

touch plans/2021-CW{01..52}/{work,sport,shopping,music}.txt
$ ls plans/2021-CW*
plans/2021-CW01:
music.txt  shopping.txt  sport.txt  work.txt

plans/2021-CW02:
music.txt  shopping.txt  sport.txt  work.txt

...

plans/2021-CW52:
music.txt  shopping.txt  sport.txt  work.txt
4
18.03.2021, 22:39

Я написал скрипт, который вы можете использовать для этого:

#!/bin/bash

mkdir -p plans/2021-CW{01..52} && cd plans

for d in */
do
    if [ -d "${d}" ] ; then 
        cd ${d} ; touch {work,sport,shopping,music}.txt ; cd..
    fi
done
2
18.03.2021, 22:39

Теги

Похожие вопросы