Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I program using cat?

In this xkcd comic: Real Programmers

they mention that real programmers use cat. Well, I was asking myself: how could you program using the cat command?


2 Answers

$ cat > hello.c
#include <stdio.h>

main(void) {
    printf("Hello, world.\n");
}
^D
$ gcc hello.c
$ ./a.out
Hello, world.
like image 165
chaos Avatar answered Sep 15 '25 04:09

chaos


Nah, echo is clearly better:

echo 'main(){puts("Hello world\n");}'  | gcc -xc -

Even if you want to use cat (felines are after all wonderful), why bother putting the source to disk? Just redirect cat's output to the compiler, as in the echo case.

like image 22
2 revs, 2 users 89%Alex Martelli Avatar answered Sep 15 '25 05:09

2 revs, 2 users 89%Alex Martelli