System Software and Labs Code Ⅱ

Dust J
Dust in the Code
Published in
1 min readJan 8, 2023
L=0; C=0
for i in `cat $1`
do
let L=$L+1
let D=$L%2
if [ $D = 1 ]
then echo $i
read -e j
else if [ $i = $j ]
then echo "(O)"
let C=$C+1
else echo "(X)"
echo $i
fi
fi
done
let L=$L/2
echo "$C / $L"

QnA

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char * argv[]) {
int L=0, C=0;
char string1[100], string2[100];
FILE *fp = fopen(argv[1], "rt");
while(fscanf(fp, "%s", string1)!=-1) {
L+=1;
if (L%2==1) {
printf("%s \n", string1);
scanf("%s", string2);
}
else {
if (strcmp(string1, string2)==0) {
printf("(O) \n");
C+=1;
}
else {
printf("(X) \n");
printf("%s \n", string1);
}
}

gcc QnA.c

./a.out/home/folder/q.txt

echo: echo [-neE] [arg …]
Write arguments to the standard output.

read: read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name …]
Read a line from the standard input and split it into fields.

cd: cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.

pwd: pwd [-LP]
Print the name of the current working directory.

let: let arg [arg …]
Evaluate arithmetic expressions.

‘cat’ Concatenate and write files

‘mkdir’ creates directories with the specified names.

‘chmod’ changes the access permissions of the named files.

gcc — GNU project C and C++ compiler

--

--