Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm imagining someone trying something along these lines:

maybe find ~/ | grep . | parallel rm {}

...and be fairly surprised to find everything deleted. It wasn't find's fault!



Why would anyone ever invoke something like this and expect maybe to somehow steal those pipe characters? It's almost meaningless and displays just enough know how that the author should know how a shell works.


Have you never run something like "sudo echo 0 > /proc/sys/..." and only realized your mistake after running it? Ever?


Is the "right solution" to use `tee`? I saw that once, and it seemed like we should be able to do better -- as if, had `tee` not been in the standard we wouldn't have any way to do it...


Alternatively: sudo sh -c 'echo 0 > /sys/foo'


You can spawn a shell as root but this is hardly any more elegant.

sudo sh -c "echo 'foo' >> /etc/file"


I use tee, but you can always do the ugly sudo sh -c "..." thing.


The parent is more similar to doing `sudo find . | grep -- "*-foo.bar" | xargs rm` which I can definitely say I've never done because it's absurd. The consequences of redirecting to a file are usually nil, unlike running rm on the output of a pipeline without at least using -n on the destructive util...


Once




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: