Earlier quoted context omitted.
I'm on MacOS... :-/ $ find ./tmp -maxdepth 1 -type f -printf '%f\n' find: -printf: unknown primary or operator
If you use brew or macports you can install the coreutils package and then you're good to go with gnu find. I also use MacOS and I have setup the gnu userland on my local so it matches the linux environment on our servers and containers.
Moreutils – Unix tools that nobody thought to write (2012)
151–160 of 225 posts
Re: Moreutils – Unix tools that nobody thought to write (2012)
#152Earlier quoted context omitted.
sponge buffers the whole input before writing the output. Its utility would be in reading from a file, working on it with other tools, and writing the result back to the original file, all in one line.
I know I wanted to do this, but I am very happy such a utility doesn't exist. Unix utilities, usually work in a pipeline fashion, read line -> process -> write to output. This allows them to allocate a limited amount of memory. If you read all input in memory, you are asking for trouble: 'cat /dev/zero | sponge a'.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#153Where 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 have it bound to ctrl-e for edit: https://gist.github.com/FeepingCreature/5f575b6fcda041a48f58...
It's like adding the vscode file finder to bash :)
The additional code is to make bash "act as if you typed in the command manually". So you can arrow-up to find it in the history buffer with the filename expanded.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#154Earlier quoted context omitted.
Yes, but -i on sed is specific to GNU, I don't think it exists on BSD/OSX/busybox
-i is definitely not specificed by POSIX, but it supported on all those platforms with some small differences, for instance on OSX the backup extension (-i.bak) is not optional.
(Would love to be proved wrong on this)
Re: Moreutils – Unix tools that nobody thought to write (2012)
#155Earlier quoted context omitted.
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.
That makes sense but in the example provided, why can't we use sed with the in-line flag?
Re: Moreutils – Unix tools that nobody thought to write (2012)
#156I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…
Re: Moreutils – Unix tools that nobody thought to write (2012)
#157There'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
> tree I agree, tree is great. It can be somehow replicated by using "find .", if you are in a hurry. > bat If you need that functionality, why don't you open the file with vim, for example? > rg - better grep Grep is pretty nifty, I don't see how could it be improved. What is the main advantage of of rg over grep? > direnv - local environment variables I read the manpage for direnv and I was really scared. What is i…
I figure you can also use it in conjunction with `module load` to automatically load the right module when you enter a project's directory. Modules are used in many computing clusters to manage environments.
Also direnv will never execute an .envrc without permission, you need to run `direnv allow` whenever there is a new or newly modified .envrc.
Re: Moreutils – Unix tools that nobody thought to write (2012)
#158Re: Moreutils – Unix tools that nobody thought to write (2012)
#159Earlier quoted context omitted.
I’ve never seen syntax highlighting in “less”.
Ha! Here’s how to have syntax highlighting while using less: https://superuser.com/questions/71588/how-to-syntax-highligh...
Re: Moreutils – Unix tools that nobody thought to write (2012)
#160I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…
How is sponge different from just normal file redirection?
% sed "s/root/toor/" /etc/passwd | grep -v joey | sponge /etc/passwd
If you tried this as: % sed "s/root/toor/" /etc/passwd | grep -v joey > /etc/passwd
The shell would overwrite /etc/passwd with an empty file before sed has a chance to read from it.