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?
An Illustrated Guide to Useful Command Line Tools
71–80 of 108 posts
Re: An Illustrated Guide to Useful Command Line Tools
#72I’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.
Re: An Illustrated Guide to Useful Command Line Tools
#73Amazing 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.
Re: An Illustrated Guide to Useful Command Line Tools
#74Can 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).
Re: An Illustrated Guide to Useful Command Line Tools
#75Earlier 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.
Re: An Illustrated Guide to Useful Command Line Tools
#76Earlier 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…
`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
#77really bad name for "dot", it has always been the graphviz interface
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.svgRe: An Illustrated Guide to Useful Command Line Tools
#78I’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.
Re: An Illustrated Guide to Useful Command Line Tools
#79Earlier 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…
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
#80A 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