Ask HN: How do I become a shell god?
1–10 of 34 posts
Re: Ask HN: How do I become a shell god?
#2Re: Ask HN: How do I become a shell god?
#3Re: Ask HN: How do I become a shell god?
#4https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...
From there, you have a better background for reading the documentation of shell implementations, like Bash.
Also study Awk:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/a...
Those who don't know Awk do comical things with cockamamie combinations of cut, sed, grep, echo ... and clumsy loops written in shell.
Other than shell syntax and semantics, it's a matter of knowing a large number of utilities.
Re: Ask HN: How do I become a shell god?
#5Files were the default datastore, and text streams the default inter-process interface.
Although the world is changing, a surprising amount of it still operates through those tools.
A good way to understand the tooling is to do one of the Linux from scratch or similar projects, perhaps look at swapping out some tools for self-written alternatives, and scratching your own itch building projects that solve problems you have yourself.
Most people who reach a degree of proficiency in shell also have an innate understanding of the kernel's general organization, the nature of filesystems, the boot process, database types, are capable of programming in multiple languages, comoprehend network programming and the challenges of locking and distributed state, and so on. You can't learn all of it in one go, so just leverage that interest and enthusiasm and devote the time.
Re: Ask HN: How do I become a shell god?
#6Then, whenever you have some everyday problem (frequently some "batch" or "bulk" job operating on many files), consider using the shell instead some 3rd party tools.
If you really are into it, consider working with suitable files. For instance, drop office files (MSO or LibreOffice/OpenDocument) and instead switch to plain text files (Markdown or Latex). They are much easier to process in the command line. Also consider using git instead of dropbox and friends, because it is CLI-first. There is a universe waiting to be explored: There are CLI clients for almost everything (chatting, mail, web, etc.).
Re: Ask HN: How do I become a shell god?
#7Honestly? If you can think of anything that needs to be automated, then write a shell script to automate it!
Re: Ask HN: How do I become a shell god?
#8Read the whole POSIX specification for the "Shell Command Language", and in particular how input is processed by the shell through all the multiple expansion passes. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V... From there, you have a better background for reading the documentation of shell implementations, like Bash. Also study Awk: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/a... Th…
Re: Ask HN: How do I become a shell god?
#9- read the manual (see other posts) - customize it (and persevere) - make it fun
The second is really helpful. A lot of my shell commands/utilities [0] are simply better-for-me ergonomics on commonly available commands. These include things like `fzf` wrappers and more sophisticated aliases.
I specifically found the making of `fzf` based utilities to be a source of major learnings. It requires you to know quite a bit of shell mechanics to do things nicely. It's very similar to building a UI with APIs. You invariably learn the surrounding concepts (HTTP, auth for APIs, content types, caching, etc.)
Re: Ask HN: How do I become a shell god?
#10Try to write small loops and pipes on the command line. I do things like this all the time:
for i in foo*.txt; do mv $i OLD-$i; done
You'll find this breaks sometimes, so use control-r to recall the command and fix it for i in foo*.txt; do mv "$i" "OLD-$i"; done
if it gets too long, copy/paste it into a file like ~/bin/renamer and multiple lines and indenting and make it a more permanent part of your collection.Also, shell isn't the end. I move to python when shell scripts get cumbersome. python can easily parse arguments (argparse), handle filenames with weird characters in them (os.path), walk trees of files (os.walk) and more.