diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-26 00:57:37 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-26 00:57:37 +0200 |
commit | c392c0d799d763edee18a452c189c48376a4f33f (patch) | |
tree | 89fc06106ca05ed313b181f8a9f34c6b3388cb12 /Userland | |
parent | 671dee9afa2e65b8887c50f74311b3782516083d (diff) | |
download | serenity-c392c0d799d763edee18a452c189c48376a4f33f.zip |
Userland: Add a simple /bin/tr program.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/tr.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Userland/tr.cpp b/Userland/tr.cpp new file mode 100644 index 0000000000..c9be4b0f3a --- /dev/null +++ b/Userland/tr.cpp @@ -0,0 +1,28 @@ +#include <AK/QuickSort.h> +#include <AK/Vector.h> +#include <AK/AKString.h> +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char** argv) +{ + if (argc != 3) { + printf("usage: tr <from> <to>"); + return 0; + } + + char from = argv[1][0]; + char to = argv[2][0]; + + for (;;) { + char ch = fgetc(stdin); + if (feof(stdin)) + break; + if (ch == from) + putchar(to); + else + putchar(ch); + } + + return 0; +} |