Echo (command) - Implementation Example

Implementation Example

The echo command can be implemented in the C programming language with only a few lines of code:

#include #include /* echo command-line arguments; 1st version */ int main(int argc, char *argv) { int i; for (i = 1; i < argc-1; i++) { (void) printf("%s%s", argv, " "); } (void) printf("%s%s", argv, "\n"); return EXIT_SUCCESS; }

Perl can also emulate echo quite simply:

#!/usr/bin/env perl print join " ", @ARGV;

Read more about this topic:  Echo (command)