4 ms·
Knowing the command line is one of those unsung critical skills of being a software engineer. Doesn't really matter so much what flavor of command line you're u
by necrotic_comp 3y ago
Knowing the command line is one of those unsung critical skills of being a software engineer. Doesn't really matter so much what flavor of command line you're using (though bash is great for obvious reasons), but the ability to glue different, disparate commands together through pipes is one of the most efficient ways of getting throwaway work done. Heck, just knowing IFS=$'\n' and how to do a for loop will get you a long way.
- fellerts 3y agoShellcheck and cheat.sh will get you most of the rest of the way!
- sirwitti 3y agoDidn't know about cheat.sh. Thank you for that, I love it!
- LinuxBender 3y agoAlso CommandLineFu [1] has some halfway decent examples for those that learn better from examples. In may be best to test the examples in a throw-away VM as things change and environments may differ. [1] - https://www.commandlinefu.com/commands/browse https://www.commandlinefu.com/commands/browse
- nickjj 3y ago> Knowing the command line is one of those unsung critical skills of being a software engineer. Yep, the command line is what lets you solve "We have 178 CSV dumps of tables that has ~60 GB of data and we want them imported into a SQL database, there's no previous DB schema info, here's a zip file of questionably named CSVs, can you have this done in 2 days?". Meanwhile there's 8,000+ columns of data that are strings, booleans, datetimes, etc. and some of the files are 15 GB each. It didn't take too much shell scripting to solve that problem in a way that you can run it against a directory of CSV files and have it produce SQL files with table schemas that can be created and then generate the SQL to efficiently import them from a CSV. Basically a little bit of shell scripting and using tools like find, head, sed, grep, wc and friends. It took 4 hours to solve the problem in a way that was testable.
- remram 3y agoI would have reached for Python/Perl at this point, just because something can be done with bash and sed doesn't mean it should (not a diss, you got it done so you were right)
- necrotic_comp 3y agoyep, I recently did something similar with data that wasn't updated properly and programmatically generated thousands of targeted SQL statements to fix our database. A little bit of python and a lot of shell scripting. One of my biggest moments was figuring out you could run SQL from the command line, using environment variables in the query string.
- fuzztester 3y ago>One of my biggest moments was figuring out you could run SQL from the command line, using environment variables in the query string. Ha ha, nice. You can do something similar to that with awk. The classic book titled The Unix Programming Environment, by Kernighan and Pike, has some good examples of that. https://en.m.wikipedia.org/wiki/The_Unix_Programming_Environment https://en.m.wikipedia.org/wiki/The_Unix_Programming_Environ... You have to quote and unquote parts of the awk command appropriately, so that some parts of the command are processed directly by awk, and others by the shell (first).
- deleted 3y ago[deleted]
- TristanBall 3y ago
- HankB99 3y agoThe Unix Programming Environment - Kernighan and Pike Got me started. Probably still useful, hardly available (unless your library has it.)