Hacker News new | ask | show | jobs
by ahawkins 2011 days ago
If you encounter a problem or task, then do it using shell commands. This will push into asking the question "what command can do X?" and "how do I connect command X to command Y?" and "how do loop commands over output?". Then just keep doing that over and over again.

Learn the shell chainsaw: `xargs`. `xargs -L` vs `xargs` and `xargs -I` (examples will say use `{}` but I'm partial to `xargs -I @` because that works with Fish and Bash, plus it's a single character.

2 comments

I enjoy intentionally avoiding some uses of the chainsaw by instead piping into "while read -r", and hence getting a loop body with some room to manoeuvre.
Can you explain or link further about the “chainsaw?” Google comes back with this post.
I think they just meant that xargs is a really powerful versatile tool, like a chainsaw. But also feel free to look up one of my favorite talks on YouTube... Just search for "Unix chainsaw" and it should come up