Live data from Hacker News

An Illustrated Guide to Useful Command Line Tools

wezm.net

71–80 of 108 posts

Re: An Illustrated Guide to Useful Command Line Tools

#71
post #70

Earlier quoted context omitted.

This suggestion is exactly why fd is so helpful. With zmv I can rename files in a directory. Great. But what if I want to count the number of total files within each directory? Create tarballs out of each directory? Rename files that contain the word "FOOBAR" in them? I can do this with fd and similar tools with slight modifications. With zmv I can rename files.

How do you rename files based on contents with fd?

I would use rg. My original point is not that fd is a do anything tool, it’s that fd and others are a much better replacements for find, grep, etc that when I want to do something complex they’re much better starting places.

Re: An Illustrated Guide to Useful Command Line Tools

#72

I’m gonna sound like an old person here. As much as these tools are gorgeous and ergonomic, remember that the others are standard, which means they’re available (almost) everywhere. Still though, these alternatives seem great for productivity locally, even if they’re not usable in a script.

ripgrep is included in some linux distros standard now.

Re: An Illustrated Guide to Useful Command Line Tools

#73

Amazing how many of those are written in Rust and Go.

I don't think it says much about the tools themselves though, it just makes sense when you look at the author's GitHub and see a bunch of Rust projects.

CLI tools have pretty strong needs to be self contained exes that start up fast. That rules out a lot of the more popular languages.

Re: An Illustrated Guide to Useful Command Line Tools

#74

Can someone explain the misuse of cat, which bat solves?

I guess the author was thinking of how cat's original purpose is to concatenate multiple files, not show just one file. (But I certainly don't think using cat in the latter way is a misuse.) There's also a commonly noted "unnecessary use of cat" where people do this: cat file.txt | grep foo instead of this: but that's not relevant to bat (which can be used unnecessarily in the same way).

What's the name of the bash feature with the '<' before the filename? I want to read the docs on it but I don't even know what to search for.

Re: An Illustrated Guide to Useful Command Line Tools

#75
post #74

Earlier quoted context omitted.

I guess the author was thinking of how cat's original purpose is to concatenate multiple files, not show just one file. (But I certainly don't think using cat in the latter way is a misuse.) There's also a commonly noted "unnecessary use of cat" where people do this: cat file.txt | grep foo instead of this: but that's not relevant to bat (which can be used unnecessarily in the same way).

What's the name of the bash feature with the '<' before the filename? I want to read the docs on it but I don't even know what to search for.

input redirection: https://www.tldp.org/LDP/abs/html/io-redirection.html

Re: An Illustrated Guide to Useful Command Line Tools

#76

Earlier quoted context omitted.

You are right, it does not. But the find command is not too complicated, or different from the one above.

find has awful ergonomics that are completely unlike any other common unix tool. I can never remember the syntax, how the flags work, or what order things need to be in. Let's use an example I just dug up of using find: To list and remove all regular files named core starting in the directory /prog that are larger than 500KB, enter: find /prog -type f -size +1000 -print -name core -exec rm {} \; OK first, how in the…

While I agree that find has weird quirks to my liking, your example is not a great one. I would write the find as follows:

`find /prog -type f -size +500k -name core -delete`

Alternative:

`find /prog -type f -size +500k -name core -exec rm -v {} +`

For extra context:

`-print` will just show you the results before `rm`'ing.

When the command ends with `\;`, the command will be repeated for every match. If the command ends with `+`, the results are appended until max args is reached (and then repeated). This is not always possible, but when it is, it's way easier to use. Less calls to the command, but certainly useful when appending the command after an ssh command, which would mean any number of extra `\` to escape the original `\`...

Re: An Illustrated Guide to Useful Command Line Tools

#77

really bad name for "dot", it has always been the graphviz interface

Indeed, and graphviz's dot is really useful, too. It makes it really easy to make all sorts of graphs. For example, if I wanted to make a dependency graph of all the packages I have installed in Archlinux, I can use it like this:

  pacman -Qq | xargs -r pacman -Qi | awk '
    BEGIN { print "digraph deps {" }
    /^Name/ { n = $3 }
    /^Depends On/ {
      for (i = 4; i  \"" $i "\";"
    }
    END { print "}" }
  ' | dot -Tsvg > package-deps.svg

Re: An Illustrated Guide to Useful Command Line Tools

#78

I’m gonna sound like an old person here. As much as these tools are gorgeous and ergonomic, remember that the others are standard, which means they’re available (almost) everywhere. Still though, these alternatives seem great for productivity locally, even if they’re not usable in a script.

I don't think its old fashioned at all, the arguments are solid. It's just like `uname -a` works under freeBSD, linux, darwin et all. The standard tools rule supreme IMHO.

Re: An Illustrated Guide to Useful Command Line Tools

#79
post #76

Earlier quoted context omitted.

find has awful ergonomics that are completely unlike any other common unix tool. I can never remember the syntax, how the flags work, or what order things need to be in. Let's use an example I just dug up of using find: To list and remove all regular files named core starting in the directory /prog that are larger than 500KB, enter: find /prog -type f -size +1000 -print -name core -exec rm {} \; OK first, how in the…

While I agree that find has weird quirks to my liking, your example is not a great one. I would write the find as follows: `find /prog -type f -size +500k -name core -delete` Alternative: `find /prog -type f -size +500k -name core -exec rm -v {} +` For extra context: `-print` will just show you the results before `rm`'ing. When the command ends with `\;`, the command will be repeated for every match. If the command e…

TIL, but that’s my point. If after many years of doing this and leading the development on one of the top utilities on homebrew I don’t immediately know the answer to these things, how could anyone.

UX is FAR more important in the CLI than even on the web. Users don’t just have to be able to learn what they want to do, for these common tools they have to memorize it or they won’t use it. Minor things like the order of the flags and bits like having to escape the semicolon don’t just make it challenging. I would argue for 99% of users they make it impossible.

In other words, I think 99% of users don’t know how to use this level of find and will never learn. That’s a problem and no amount of education is going to fix it. The tool itself is broken.

Re: An Illustrated Guide to Useful Command Line Tools

#80
post #16

A number of the utilities mentioned here (bat, fd, hexyl) are made by the same author, who makes a number of additional command line utilities in Rust. They're all rather easy to use and aesthetically pleasing, I'm a fan of their work: https://github.com/sharkdp

This man is also creating awesome tools: https://github.com/BurntSushi
Post reply on HN