Live data from Hacker News

Show HN: I wrote a modern Command Line Handbook

commandline.stribny.name

81–90 of 115 posts

Re: Show HN: I wrote a modern Command Line Handbook

#85
post #4

Honestly I would’ve liked to fork over cash for a book like this but the deal breaker for me is that it’s in PDF format. I like to read all of my books on a Kindle (with koreader installed) so epub files that can be resized to fit its weird dimensions are a must.

You can use calibre and convert it, most of the time the result is very good.

Re: Show HN: I wrote a modern Command Line Handbook

#87
post #36

Earlier quoted context omitted.

Get really comfortable with find and grep. They’re incredibly powerful. perl -pe is way easier than awk.

I'll second that. And would like to add that find plus xargs is important to know, as it often works much better than the clumsy "exec in find itself. Oh, and thus of course find ... | xargs perl -lne "fancy stuff" to do some fancy stuff with found files ;-)

I really think you should use:

    find ... -exec perl -lne "fancy stuff" {} +
because for one it doesn't mess with stdin, and for another you don't have to worry about filenames with spaces or newlines in them. I also like -execdir since if my script dumps any output to other files I'll probably want that output near the sources. And did I mention it does nothing if there are no matching files? I also think it looks better and is shorter.

If you really can't remember that or want to continue to pollute the environment with extra heat generated by running two cpus to do the job one can do, you should at least use -print0/xargs -0 because of spaces, and always use -r to more sensibly handle an empty result-set from find et al (gnu xargs runs once!)

Re: Show HN: I wrote a modern Command Line Handbook

#88

#1 thing in command line shell scripting should be: "Do not use it for advanced scripts. If you have multiple if statements and for loops, rewrite it in a higher level language." This is also the advice given in the google shell guide. I say this after years of being a DevOps and Platform engineer. Bash is trash. It is great for 10-20 line scripts. Beyond that, it is worthless.

Is there an explanation why? (Average line count in my scripts is 115).

Re: Show HN: I wrote a modern Command Line Handbook

#90

Example pages here: https://drive.google.com/file/d/1PkUcLv83Ib6nKYF88n3OBqeeVff...

Page 12 of the example pdf ends with "On Linux, the PATH looks something like this:", but then there's no PATH example shown.

Page 13 isn't in the example pdf. It's a bunch of scattered pages to give you a feel for the whole thing.
Post reply on HN