Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

e.g I want to add

127.0.0.1 www.google.com

to the /etc/hosts file from server using C programming language.

share|improve this question
Generally, no, you need code running on the client to modify files on the client. This isn't a programming site, BTW. – Mat Oct 28 '12 at 18:25

closed as off topic by Mat, jasonwryan, Renan, Gilles, warl0ck Oct 29 '12 at 0:04

Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

Just read through the file, build a hash table, and see if the mapping already exists, if not, add it, and finally print everything out.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.