I know, it's only AWKward, but I like it...


A nice little Awk program that generates git directories per language based on the contents of two files:

BEGIN {
    file="langs.txt"; 
    while((getline < file ) > 0 ) { 
        langs[$1] = 1  # record each language
    }   
}

/^$/ { }     # blank lines allowed

/^\;/ { }    # allows comments in the chapter file

/^[IVXCM]/ { } # skip the major section names

/^[0-9]/ {
    print $2
    for( lang in langs ) { 
        new_dir = lang "/" $2
        if (system( "[ -d " new_dir " ] ") == 0)
            print new_dir " already exists."
        else {
            print "We are going to add " new_dir
            if (system( "mkdir " new_dir) == 0) {
                system( "touch " new_dir "/README")
                system( "git add " new_dir "/README")    
            }   
        }   
    }   

}

Comments

Popular posts from this blog

Libertarians, My Libertarians!

"Machine Learning"

"Pre-Galilean" Foolishness