Quickly Generate a README Under Every Direct Folder of a Folder

Quickly needed to generate a README.md under every folder of a folder that contains custom node packages

The output of the following command:

find
1
find . -type dir -depth 1

gives me this:

lang: Custom Node Modules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
./containers
./core_utils
./defining_classes
./delegation
./expect
./extensions
./fakes
./jspecs
./key_generator
./load_path
./logging
./matching
./namespace
./node_bootstrap
./resolution_root

.

I was getting tired of seeing missing readme warning when vagrant provisioning, so I wrote the following:

Generate Readme
1
2
3
4
5
6
for module in $(find . -type dir -depth 1 | sed "s/\.\///");
do
  pushd $module
  echo \#$module > README.md
  popd
done

I used sed to get rid of the the leading ./ so I can use the output for the title in the readme file.

That quickly generates a file called readme.md under each custom node package that is being maintained in the folder that I am in.

It’s good to break out the shell scripting foo every now and then!!

Develop With Passion®

Comments