0

I was reading "The C Programming Language" by Kernighan & Ritchie and came across some programs which mimic some Unix commands (also implemented in Linux) such as the cat command. The program took command line arguments just like the original cat command. I am just curious to know whether they are the same thing or not. Correct me if I'm wrong, any help would be appreciated.

arghhjayy
  • 127
  • 1
  • 8
  • Per your headline, the answer is yes. But voting to close, as this is off-topic for Stackoverflow. Good luck. – shellter Oct 08 '16 at 13:54
  • 3
    You mean Brian W. Kernighan and Dennis M. Ritchie? The folks who invented C to invent Unix? And you're wondering that their `cat` command resembles the `cat` used today? – deamentiaemundi Oct 08 '16 at 13:55
  • Many of these commands are, on some Linux-distributions, part of GNU's coreutils package. You can find the source code for many of these tools [here](http://git.savannah.gnu.org/cgit/coreutils.git/tree/src). – implmentor Oct 08 '16 at 14:14
  • K&R's cat probably took fewer options than today's cat. – Mark Plotnick Oct 08 '16 at 16:23
  • @MarkPlotnick And how! The original `cat` had *zero* options, and when it got its first one, there were cries of alarm from the die-hard Unix old guard, and one of them wrote a widely-circulated essay, *cat -v Considered Harmful*. – Steve Summit Oct 08 '16 at 19:32

1 Answers1

1

In a command-line environment (such as, of course, Unix/Linux), a principle unit of abstraction is the command. A command has a well-defined interface: the command-line arguments it expects, the input it reads (if any), and the output it generates. You can reimplement a command any time you like, either using a different internal algorithm, or a different language, or just because you want to write your own version. Yes, cat was originally written in C, but we could rewrite it in C++, or Perl, or Python, or sh, or other languages. As long as our reimplementation meets the same interface requirements, we can accurately say that it "is" cat.

Steve Summit
  • 45,437
  • 7
  • 70
  • 103