4 ms·
Every time I stumble across moreutils, I can’t understand what any of its tool do. Take all these for instance: pee: tee standard input to pipes sponge: soak
by thiht 5y ago
Every time I stumble across moreutils, I can’t understand what any of its tool do. Take all these for instance:
pee: tee standard input to pipes
sponge: soak up standard input and write to a file
ts: timestamp standard input
vidir: edit a directory in your text editor
vipe: insert a text editor into a pipe
zrun: automatically uncompress arguments to command
Wth do they do? What does any of this means? I know tee but have no idea what « tee stdin to pipes » would do
- oftenwrong 5y agoYou will want to read the man pages. 'pee' is straightforward to understand if you already understand 'tee'. 'pee' is used to pipe output from one command to two downstream commands. https://en.wikipedia.org/wiki/Tee_(command) https://en.wikipedia.org/wiki/Tee_(command)
- thiht 5y agoI know tee but have no idea what pee would do considering this description. From your description I guess something like « pee a b » would be the same as « a | b »? If so that’s cool, but the one line descriptions definitely need a rework.
- nerdponx 5y agoI believe it's more like `a | pee b x y z | c`. This would run `b x y x` as well as `c` using the output from `a`. I think Zsh supports this natively with its "multios" option, `a > >(b c y z) > >(c)`. But then you have to write the rest of your pipe inside the ().
- somat 5y agoI can only guess from that description is that it is the cat command.
- oftenwrong 5y agoIt loosely follows the same metaphor as the T-shaped pipe connector that 'tee' is named for. $ seq 3 | tee somefile 1 2 3 ╔═somefile seq═tee═╣ ╚═stdout $ seq 10 | pee 'head -n 3' 'tail -n 3' 1 2 3 8 9 10 ╔═head═╗ seq═pee═╣ ╠═stdout ╚═tail═╝
- somat 5y agoThe unix shell was designed to optimize for simple pipes. to make pipe networks you usually have to use named pipes, aka fifos. I once had to use an IBM mainframe shell(cms If I remember correctly) which had pipes however IBM in their infinite wisdom decided to make the pipe network the primary interface, while this made complex pipes a bit less awkward, simple(single output) pipes were wordy compared to the unix equivalent.
- chriswarbo 5y ago`ts` is like `cat`, but each line gets prefixed with a timestamp of when that line was written. Useful when writing to log files, or finding which step of a program is taking the most time. `sponge` allows a command to overwrite a file in-place; e.g. if we want to replace the contents of myfile.txt, to only keep lines containing 'hello', we might try this: grep 'hello' < myfile.txt > myfile.txt However, this won't work: as soon as grep finds the first matching line, the entire contents of the file will be overwritten, preventing any more from being found. The `sponge` command waits until its stdin gets closed, before writing any output: grep 'hello' < myfile.txt | sponge > myfile.txt