diff --git a/1-lower/test0-result.txt b/1-lower/test0-result.txt index 01cdea1..1770a59 100644 --- a/1-lower/test0-result.txt +++ b/1-lower/test0-result.txt @@ -1 +1 @@ -tar heels \ No newline at end of file +tar heelsbruh diff --git a/2-bash/pipe.sh b/2-bash/pipe.sh index cc1f786..e2627dd 100755 --- a/2-bash/pipe.sh +++ b/2-bash/pipe.sh @@ -1 +1,2 @@ -#!/bin/bash \ No newline at end of file +#!/bin/bash +awk '/^cd/' $HISTFILE | wc -l diff --git a/2-bash/redirection.sh b/2-bash/redirection.sh index cc1f786..60d7799 100755 --- a/2-bash/redirection.sh +++ b/2-bash/redirection.sh @@ -1 +1,2 @@ -#!/bin/bash \ No newline at end of file +#!/bin/bash +diff <(./lower < test0.txt) test0-result.txt diff --git a/3-truncator/truncator b/3-truncator/truncator new file mode 100755 index 0000000..54f9df4 Binary files /dev/null and b/3-truncator/truncator differ diff --git a/3-truncator/truncator.c b/3-truncator/truncator.c index 93c73dd..6b36a71 100644 --- a/3-truncator/truncator.c +++ b/3-truncator/truncator.c @@ -1,2 +1,44 @@ -// PID: 9DigitPidNoSpacesOrDashes +// PID: 730677144 // I pledge the COMP 211 honor code. + +#include +#include + +int main() { + int lines[100]; + int total, chars, cur, c; + + total = 0; + chars = 0; + cur = 0; + + while ((c = getchar()) != EOF) { + chars++; + + if (c == '\n') { + chars = 0; + cur++; + putchar(c); + } else if (chars > 50) { + if (total == 0 || lines[total-1] != cur) { + lines[total] = cur; + total++; + } + + chars = 1; + putchar('\n'); + putchar(c); + } else { + putchar(c); + } + } + + printf("Total lines over 50 chars: %d\n", total); + printf("Offending lines: "); + for (int i = 0; i < total; i++) { + printf("%d, ", lines[i]); + } + printf("\n"); + + return 0; +}