Add pipe-out which acts as > for pipes
This commit is contained in:
parent
49a4251830
commit
2e65c8667f
19
userspace/extra/pipe-out.c
Normal file
19
userspace/extra/pipe-out.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
if (argc < 2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE * out = fopen(argv[1], "w");
|
||||
|
||||
while (!feof(stdin)) {
|
||||
char buf[1024];
|
||||
size_t r = fread(buf, 1, 1024, stdin);
|
||||
fwrite(buf, 1, r, out);
|
||||
}
|
||||
fflush(out);
|
||||
fclose(out);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user