There's a few programs I wish were standard on all Unix systems by now: * tree - print directory structure * bat - cat, but actually designed for reading files. Syntax highlighting, line numbers, automatic paging. * rg - better grep * direnv - local environment variables
> rg Never going to happen because it's written in rust. ag ( https://github.com/ggreer/the_silver_searcher ) on the other hand is written in C.
Moreutils – Unix tools that nobody thought to write (2012)
81–90 of 225 posts
Re: Moreutils – Unix tools that nobody thought to write (2012)
#82Nice collection of quite useful tools. Some of these can be easily replicated by using a more modern shell (bash, zsh) like mispipe, others are just shortcuts (e.g. ifne, chronic). But what immediately stood out to me is `vidir`. I really like the idea of editing file names with an editor. Using loops and regex in a shell for mass renaming can be a mess. It should be way easier with `vim`. This tool made me install m…
On most POSIX systems you can use fc(1) to edit a command in your $EDITOR. In vi(1) and friends you can then use "%!ls" to replace the contents of the buffer with directory listing and edit the commands you want. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/f... https://pubs.opengroup.org/onlinepubs/9699919799/utilities/v...
Re: Moreutils – Unix tools that nobody thought to write (2012)
#83 xclip -o | vipe | xclip
This one in particular, let's you edit your clipboard with $EDITOR.Re: Moreutils – Unix tools that nobody thought to write (2012)
#84What is the difference between `sponge` and redirecting with `>` (or `>>`)? Is it about better compatibility with pipes or something?
Some commands (eg. sed) have an in-place option, but many don’t.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#85> sponge: soak up standard input and write to a file
I do that all the time...
cat > file.txt
Update: reading the comments on here, apparently sponge sucks up all content before opening the destination file which allows editing an input file in place. Minor advantage there.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#86Where is Msdos utility "ncd"? It was like "cd" but guessed from few character hint where you wanted to go. If the choice was not immediately obvious if offered a menu or a tree. I shortened it to "n". -- There was some linux utility but setting it up was annoyingly tedious, with lots of useless and cryptic options.
Yes, the find -type f focuses on files; nonetheless it's easy enough to right-click-select the relevant directory to open it rather than the file.
#!/usr/bin/env rc
if (~ `{find -type f | 9 grep $1 | wc -l} 1)
plumb `{find -type f | 9 grep $1}
if not
find -type f | 9 grep $1Re: Moreutils – Unix tools that nobody thought to write (2012)
#87Nice collection of quite useful tools. Some of these can be easily replicated by using a more modern shell (bash, zsh) like mispipe, others are just shortcuts (e.g. ifne, chronic). But what immediately stood out to me is `vidir`. I really like the idea of editing file names with an editor. Using loops and regex in a shell for mass renaming can be a mess. It should be way easier with `vim`. This tool made me install m…
Also if you happen to use fern[0] you can mark off multiple files and directories, hit a hotkey and now you can edit their paths in a Vim buffer.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#88A lot of these seem easily achieved in a POSIX shell manner, but most annoyingly to me > sponge: soak up standard input and write to a file I do that all the time... cat > file.txt Update: reading the comments on here, apparently sponge sucks up all content before opening the destination file which allows editing an input file in place. Minor advantage there.
grep foo file.txt | sponge file.txt
If you do this with redirections then file.txt will be truncated before it's been processed, leaving you with an empty file instead of what you wanted. Sponge collects its input first and then writes everything out at the end, so you can output to a file that was used as an input.
(Parent updated while I was writing. Oh well)
Re: Moreutils – Unix tools that nobody thought to write (2012)
#89A lot of these seem easily achieved in a POSIX shell manner, but most annoyingly to me > sponge: soak up standard input and write to a file I do that all the time... cat > file.txt Update: reading the comments on here, apparently sponge sucks up all content before opening the destination file which allows editing an input file in place. Minor advantage there.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#90> sponge Why not use > file? > mispipe In bash there's PIPESTATUS for that.
Re sponge: the shell will open the output file for writing before invoking the command so in the example joey provides, /etc/passwd will be an empty file by the time sed opens it.