[PLUG] source code of echo command...

Vaibhav Kulkarni netvaibhav at gmail.com
Sat Jul 28 09:13:40 IST 2007


On 7/27/07, Sameer Oak <sameer.oak at gmail.com> wrote:
> Where can I find source code of "echo" command?

Here's a minimal echo that does not handle options (-n, -e, etc.)

int main(int argc, char *argv[])
{
  int i;
  for (i = 1; i < argc; i++) printf("%s ", argv[i]);
  printf("\n");
  return 0;
}

echo command is nothing but printing of its arguments.

Note: above program not tested. Also has an obvious bug: prints an
extra space at the end if it has 1 or more arguments (I just wanted to
keep it simple).

-- 
Vaibhav




More information about the Plug-mail mailing list