Live data from Hacker News

Moreutils – Unix tools that nobody thought to write (2012)

joeyh.name

61–70 of 225 posts

Re: Moreutils – Unix tools that nobody thought to write (2012)

#62

Earlier quoted context omitted.

But the top answer has it: > find . -maxdepth 1 -type f A little clunky, but there's certainly no need to mess about in JavaScript land. If you use it often, create a shell macro.

find doesn't return the same output as ls when run on another directory. Maybe there is a switch to do this? I'm not sure. $ mkdir -p tmp && touch tmp/a tmp/b tmp/c $ find ./tmp -maxdepth 1 -type f ./tmp/a ./tmp/c ./tmp/b $ ls -1 ./tmp a b c

The -ls flag to find prints the same as ls

Re: Moreutils – Unix tools that nobody thought to write (2012)

#64

What is the difference between `sponge` and redirecting with `>` (or `>>`)? Is it about better compatibility with pipes or something?

Well one thing is that if you’ve tried it you’ll run into the problem he illustrates there that you are writing to the Sam file you are reading from, which won’t work right.

My guess is sponge buffers all the input and then sends it to output once stdin is closed.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#66

What is the difference between `sponge` and redirecting with `>` (or `>>`)? Is it about better compatibility with pipes or something?

I wondered this too so looked at the man page [1]

> Unlike a shell redirect, sponge soaks up all its input before opening the output file. This allows constricting pipelines that read from and write to the same file.

[1] https://linux.die.net/man/1/sponge

Re: Moreutils – Unix tools that nobody thought to write (2012)

#67

Earlier quoted context omitted.

Rust is designed for a fairly small number of relatively modern systems; there are many close-to-POSIX systems that can’t (and I would guess likely will never) be able to run Rust code in any formal capacity. To the hopeful: even C++ has been unable to win here, despite having many more years of a head start and much more accommodation for stranger platforms. It’s just not going to happen.

What kind of platforms are you thinking of? People have got Rust running on the Raspberry Pi. https://old.reddit.com/r/rust/comments/cdcads/

Linux on ARM is a very mainstream platform from the perspective I’m looking at this from, I’m afraid. I’m talking about strange Unices running on architectures that GCC may or may not maintain a backend for, or maybe a BusyBox available on some debug interface, maybe a school project to build a simple POSIX-compatible OS or a bootstrap for a platform that had been recently jailbroken. In these cases C is almost always the go-to language and I suspect it will remain so for the foreseeable future as this is precisely the long tail of distributions that standards were intended to provide a base set of tooling for.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#68
post #55

Where 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.

I think that's the default behaviour in Zsh or Fish if you press tab.

Probably immediate subdir. What I am talking about is universal jump-to-anywhere.

Like I have subdir "/media/tnoko/sdc1/capture/Roinaa/".

"ncd Roi" should be totally sufficient and unique command to go there.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#69

Earlier quoted context omitted.

But the top answer has it: > find . -maxdepth 1 -type f A little clunky, but there's certainly no need to mess about in JavaScript land. If you use it often, create a shell macro.

find doesn't return the same output as ls when run on another directory. Maybe there is a switch to do this? I'm not sure. $ mkdir -p tmp && touch tmp/a tmp/b tmp/c $ find ./tmp -maxdepth 1 -type f ./tmp/a ./tmp/c ./tmp/b $ ls -1 ./tmp a b c

I think this is what you are looking for

    $ find ./tmp -maxdepth 1 -type f -printf '%f\n'

Re: Moreutils – Unix tools that nobody thought to write (2012)

#70
post #27
post #15

Nice 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...

> you can then use "%!ls" to replace the contents of the buffer with directory listing and edit the commands you want.

I often used :r !ls for that, thanks for the tip + it's shorter

Post reply on HN