sawyl: (Default)
[personal profile] sawyl
We've been playing a geeky game this week: come up with a way of listing the contents of /etc/hosts when the obvious file manipulation tools on your system are missing or broken. The solutions included:

grep ^ /etc/hosts
sed "" /etc/hosts
gzip -c /etc/hosts | gzcat
diff /dev/null /etc/hosts

My own, favoured, solution involves doing away with external tools and using the existing login shell to do the heavy lifting:

while read X; do echo $X; done < /etc/hosts

It's a neat hack because it's entirely self contained and because you're almost guaranteed to have some form of Bourne shell available to you, no matter how shredded the rest of the system is. I mean, if you don't have sh you're not even going to be able to start single user and the whole exercise becomes even more academic than it already is...

Profile

sawyl: (Default)
sawyl

August 2018

S M T W T F S
   123 4
5 6 7 8910 11
12131415161718
192021222324 25
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 4th, 2026 01:10 pm
Powered by Dreamwidth Studios