by throwaway0a5e · 5y ago · 0 comments
Everything is basically either a formatted input or a formatted output at the end of the day. Trying to shoehorn things into data "structures" that enable efficient access in certain cases rarely makes sense because of all the processing you need to do to get it there in the first place and it winds up being more efficient just deal in formatted streams of data even if you need to deal with some ugly nested loops and function calls to do it.
We did a bunch of stuff with “xargs”. He said it was the one misunderstood command. One of the cool things was the ability to parallelize the work with a simple -P flag.
You do a find, make sure to use the -print0 flag, pipe it into xargs and use the -0 option then run a command over all the files. If you add -P it magically becomes parallel.
I spend half my time trying to find the right arguments and the whole time wishing I just bit the bullet at the start and used a real programming language.
And god forbid if a filename might have a quote character or a space in it. Then you have to think 5x as hard about what you're doing.