3 ms·
I contribute to a niche game server project and used awk to generate c# class files from an org mode document that I wrote to specify them.
by na85 7y ago
I contribute to a niche game server project and used awk to generate c# class files from an org mode document that I wrote to specify them.
- bcyn 7y agoWhat about awk makes that easier than, say, a Python script?
- na85 7y agoProcessing text files line by line is trivial in awk. Maybe it's easy in Python too but at least in awk you don't have to worry about the 2 vs 3 silliness. Plus I think semantic indentation is not sane language design. Plus you can pipe it to another command with ease.
- 7thaccount 7y agoAwk automatically operates on every line of a text file, so you can easily use it as part of a pipeline in Linux. I'll usually use grep, cut, sort, and awk all together with one line of code and no need to open an editor. Python takes a lot more code to do these basic things. However, Python is much better once the complexity grows past a certain point.
- asicsp 7y agodepends upon the usecase, for relatively simple column filtering, substitution, etc, awk script would be briefer than python equivalent and most likely be faster as well if it becomes lengthy (and again depends on features required), then Python is likely to have inbuilt/3rd-party libraries to make it easier to write and maintain if it is a question of constructing command line one-liners and using it as a part of other cli tools, then awk wins easily for example: awk -F'\\W+' -v OFS=, '{print $NF, $2}' input.txt prints last column and second column, where non-word characters form the field separator and comma is used as output field separator