Given:
* a bunch of files where each row is a country title.
Find:
* transform the given files bunch to a directory bunch where each directory contains a sub directory for each country.
Solution:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/bin/sh expand() { region=$1 if test $region != expand.sh then mkdir ${region}_ for country in `cat $region` do mkdir ${region}_/$country done fi } for region in `ls` do expand $region done |
A little work is still needed before (remove spaces, fix characters case to match naming convention) and after (remove given files, rename new directories - remove trailing underscore characters) executing the script.
And one more script to add properties file in each country (this also useful to make git to add the directory structure to source countrol).
1 2 3 4 5 6 | #!/bin/sh for country in */* do touch ${country}/props done |