`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:
`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:
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: