Crates.io | rw |
lib.rs | rw |
version | 1.0.1 |
source | src |
created_at | 2019-05-05 04:28:37.697729 |
updated_at | 2019-10-08 18:25:06.165521 |
description | Like sponge, but without the moreutils kitchen sink |
homepage | |
repository | https://github.com/jridgewell/rw |
max_upload_size | |
id | 132176 |
size | 4,925 |
Like sponge, but without the moreutils kitchen sink.
cat example.txt | grep -v exclude | rw example.txt
rw
("rewrite") allows you to redirect the stdout of one command into a file, even if you're using that file to generate the stdout. If you were to try that with standard shell redirection, you would end up truncating the file before you could read it!
# This causes example.txt to be empty
# Shell redirection would truncate the file, before the cat utility read it
cat example.txt | grep -v exclude > example.txt
rw [-a] FILE
Giving the -a
will append to the output file, instead of overwritting it.