4 ms·
This is the sort of thing a combination of bash/grep/awk/sed is good for also.
by lighthawk 11y ago
This is the sort of thing a combination of bash/grep/awk/sed is good for also.
- kondro 11y agoTrue, but if you write Ruby all day and are most familiar with it, a script like this takes a matter of minutes to write compared to trawling the man pages of grep/awk/sed to implement the same thing you're only going to throw away after execution anyway.
- sigzero 11y agoSure if you control the environment and can install Ruby. grep/sed/awk are always installed.
- omarqureshi 11y agoPortability becomes a problem though. GNU vs BSD sed/grep :(
- adrusi 11y agoThey do have a shared subset of features defined by POSIX. It's limiting and takes discipline, but it's not really impractical.
- dragonwriter 11y agoPresumably, if you write ruby all day, there is a good chance that the environments you encounter have ruby installed, as well (and they might be even be Windows environments, in which case grep/sed/awk are not "always installed.")
- ricardobeat 11y agoAfter you are familiar with the shell tools, it takes seconds to write something like this, not minutes.
- mirceal 11y agowhatever gets the job done faster. if you treat it like throw-away it does not really matter.