/tee.c (1433a0105fd7a07e7ede04214e26552241f36b64) (1178 bytes) (mode 100644) (type blob)
/*
Copyright (c) 2019 Matthew Graham
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#define MAXBYTES 100000
int main(int argc, char *argv[])
{
unsigned int aflag=0;
char buf[MAXBYTES];
FILE *filep;
fread(buf, sizeof(buf), 1, stdin);
printf("%s", buf);
if (argc > 1) for (int i=1; argv[i]; i++) {
if (argv[i][0] == '-')
switch(argv[i][1])
case 'a': aflag = 1;
else {
if ((filep = fopen(argv[i], aflag? "a+":"w+"))==NULL) {
fprintf(stderr, "tee: unable to write to %s\n", argv[i]);
continue;
}
fputs(buf, filep);
fclose(filep);
}
}
return 0;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
35149 |
f288702d2fa16d3cdf0035b15a9fcbc552cd88e7 |
COPYING |
100755 |
blob |
676 |
b83c078041e2f7cc06ed7bde425708a9f0daf948 |
INSTALL |
100644 |
blob |
1794 |
b38b363dcdd9a397f9aeead45ca0abd624cb8993 |
README |
100644 |
blob |
4158 |
10d3ad5644471f8b188207803c01aa868158e475 |
clp.c |
100644 |
blob |
2145 |
3f3c32788285f2c294ac9381c3a39125e18f6221 |
echo.c |
100644 |
blob |
807 |
35eac8cabc2dacefe6167f615177cc86c0ea0399 |
exho.c |
100644 |
blob |
1539 |
29646d8d9c7d24d20f63cbdefd27ed7cfd120f52 |
ins.c |
100644 |
blob |
979 |
89b230aabe515c66e967be21a4d9dff3ac5248da |
nl.l |
100644 |
blob |
1932 |
d59401d46002608d4563dd4afdac5ff394ed8df4 |
sc.c |
100644 |
blob |
1004 |
b55bcc811cf0abac0308318c6c086ef94eed9c39 |
spng.c |
100644 |
blob |
1178 |
1433a0105fd7a07e7ede04214e26552241f36b64 |
tee.c |
100644 |
blob |
2099 |
f3b9072d9d355ecd3400a039b870593cc771a084 |
wc.c |
100644 |
blob |
0 |
e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |
yes.c |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/spicylord/clutils
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/spicylord/clutils
Clone this repository using git:
git clone git://git.rocketgit.com/user/spicylord/clutils
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main