http://jugad2.blogspot.in/search/label/command-line
and
http://jugad2.blogspot.in/search/label/python
should have many such posts about versions of Unix command line tools implemented by me in Python.
Also, this tutorial I wrote years ago for IBM developerWorks may be of use, to learn some of the informally handed down but generally accepted principles and techniques for writing such command line tools in C:
Developing a Linux command-line utility:
https://jugad2.blogspot.com/2014/09/my-ibm-developerworks-ar...
The post is an overview of the article I wrote for IBM, with some background about it, etc. For the actual code in C and the PDF of the IBM article, follow relevant links in the post, to more than one level, as needed.