1
0
Fork 0
pomodoro/bash_scripts/info-copy.sh
2023-12-17 07:53:27 +03:00

26 lines
1.1 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "Копирование информационных файлов и построение дерева в каждом из каталогов проектов."
cd ..
basedir=$(pwd)
milliseconds=$(date '+%s%3N')
find .. -mindepth 1 -maxdepth 1 -type d | sort -r | while read -r dir; do
echo "Обработка: $dir"
cd "$dir" || continue
if [ "${dir##*/}" != "${basedir##*/}" ]; then
cp -uv "$basedir"/CONTRIBUTING.md .
cp -uv "$basedir"/*LICENSE* .
fi
{
echo "## Дерево каталогов"
echo
echo "<pre>"
tree -nvf --dirsfirst -I "*.gem|*.lock|*.zip|_site*" --noreport
echo "</pre>"
} >DIRECTORY-TREE.md
sed -i -e "s/ / /g" -e "s/ / /g" -e "s/──/─/g" DIRECTORY-TREE.md
find . -mindepth 1 -type f,d -not -regex '.*\.\(gem\|lock\|zip\)\|.*/\(\.\|_site\).*' | sort -r | while read -r file; do
# echo "${dir#*/} => \\$file >> ${file#*/} >> ${file##*/}"
sed -i "s|\\$file|<a href='${file#*/}'>${file##*/}<\/a>|g" DIRECTORY-TREE.md
done
done
echo "Время выполнения: $(("$(date '+%s%3N')" - "$milliseconds")) мс."