$ re=root # re = "regular expression"
$ echo g/$re/p | ed - /etc/passwd # spot the command name
root:*:0:0:System Administrator:/var/root:/bin/sh
...
…in case you’re ever hacked remotely logged into a system where grep has been removed but ed remains; wrap it in a shellscript and you’re all set.
Similarly more can be lashed-up using a while-loop in Bourne shell, with a file redirect.
Leave a Reply