From 6c89dab6163c04ef0ab19472b46dacccc082ee46 Mon Sep 17 00:00:00 2001 From: Kjell Kvinge Date: Wed, 17 Jun 2015 16:44:07 +0200 Subject: [PATCH] add description and example of sponge --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 5840e2f..1f92078 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,18 @@ A few examples of piecing together commands: awk '{ x += $3 } END { print x }' myfile ``` +- `sponge`: from moreutils - soak up standard input and write to a file. I you want to change a file that is the source of a pipline: Instead of: +```bash +cat file | sort | uniq | iconv -f utf8 -t latin1 > /tmp/file && mv /tmp/file file +``` + +You can do: + +```bash +cat file | sort | uniq | iconv -f utf8 -t latin1 | sponge file +``` + + - If want to see sizes/dates on a tree of files, this is like a recursive `ls -l` but is easier to read than `ls -lR`: ```sh find . -type f -ls