Live data from Hacker News

An Illustrated Guide to Useful Command Line Tools

wezm.net

61–70 of 108 posts

Re: An Illustrated Guide to Useful Command Line Tools

#61
post #18

I quite like this list, there are a number of utilities here that I already use on a daily basis. There are also a few utilities that I like that weren't on this list, or some alternatives to what was shown. Some off the top of my head: - nnn[0] (C) - A terminal file manager, similar to ranger. It allows you to navigate directories, manipulate files, analyze disk usage, and fuzzy open files. - ncdu[1] (C) - ncurses d…

And regarding ncdu, there are static binaries for Linux. Just put them in a folder and use them.

Re: An Illustrated Guide to Useful Command Line Tools

#62
post #59

Earlier quoted context omitted.

I’ve actually found myself using these to get me much more proficient in the Shell overall. fd in particular is so much easier to use I find myself doing things like: fd .log$ -x mv {} {.}.bak (Rename *.log to *.bak) Can I do that with xargs, awk, and find? Yes, but every time I have to look up the man page to at least one of them and it’s enough friction that I might just open it in finder if it’s a handful of files…

bash/zsh: for f in *.log; do mv "$f" "${f/%log/bak}"; done a bit more generic, `for` loops and parameter expansion are good to know for proficiency, and also I dislike typing curly braces.

This doesn't move files in subdirectories? Or am I missing something?

Re: An Illustrated Guide to Useful Command Line Tools

#63

Lots of cool stuff in here. I’m going to have a long look at Restic and Syncthing. I’d like to know why Skim instead of FZF. They are pretty similar but I’ve been using the latter for years and would like to know of any possible advantages to it.

i loooove syncthing. something i set up recently is a folder called .home_sync to sync my dotfiles between computers. I have a bash script that sets up the symlinks and then version control turned on for the syncthing folder so i can have a record of any changes if I need to revert something

Re: An Illustrated Guide to Useful Command Line Tools

#64

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’ve actually found myself using these to get me much more proficient in the Shell overall. fd in particular is so much easier to use I find myself doing things like: fd .log$ -x mv {} {.}.bak (Rename *.log to *.bak) Can I do that with xargs, awk, and find? Yes, but every time I have to look up the man page to at least one of them and it’s enough friction that I might just open it in finder if it’s a handful of files…

You might like zsh if you haven't tried it. Has a builtin `zmv` that does this. Check out oh-my-zsh

Re: An Illustrated Guide to Useful Command Line Tools

#66
post #62
post #59

Earlier quoted context omitted.

bash/zsh: for f in *.log; do mv "$f" "${f/%log/bak}"; done a bit more generic, `for` loops and parameter expansion are good to know for proficiency, and also I dislike typing curly braces.

This doesn't move files in subdirectories? Or am I missing something?

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

Re: An Illustrated Guide to Useful Command Line Tools

#67

Earlier quoted context omitted.

I’ve actually found myself using these to get me much more proficient in the Shell overall. fd in particular is so much easier to use I find myself doing things like: fd .log$ -x mv {} {.}.bak (Rename *.log to *.bak) Can I do that with xargs, awk, and find? Yes, but every time I have to look up the man page to at least one of them and it’s enough friction that I might just open it in finder if it’s a handful of files…

You might like zsh if you haven't tried it. Has a builtin `zmv` that does this. Check out oh-my-zsh

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.

Re: An Illustrated Guide to Useful Command Line Tools

#68
post #48

No mention of things that have gained a lot of traction, like `ag` and `fzf` ag: - silver searcher, fast parallelized recursive grep that can abide by things like `.gitignore` fzf: - fuzzy finder powerline-shell - $PS1 on steroids

I find the to be faster than ag personally

Re: An Illustrated Guide to Useful Command Line Tools

#69
post #62

Earlier quoted context omitted.

This doesn't move files in subdirectories? Or am I missing something?

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 hell is 1000 == 500kb? Is that a bug in my example[0]? What does `-print` do exactly? And that backslash at the end? I have no clue what that signifies. I'm never going to remember this madness. I'd probably have resorted to writing a bash script in a file by now. But with fd it becomes manageable and memorable for future tasks:

To list and remove all regular files named core starting in the directory /prog that are larger than 500KB, enter:

  fd --type=file --size=+500k ^core$ ./prog -x rm {}
Now that's something that makes immediate sense even if you've never touched the tool before. Not to mention, it doesn't end up in my .git and other ignored directories.

[0] https://kb.iu.edu/d/admm

Re: An Illustrated Guide to Useful Command Line Tools

#70

Earlier quoted context omitted.

You might like zsh if you haven't tried it. Has a builtin `zmv` that does this. Check out oh-my-zsh

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?
Post reply on HN