System Software and Labs Code

Dust J
Dust in the Code
Published in
1 min readNov 30, 2022
if [ $2 = "exist" ]; then
st" ]; then
if [ -e $1 ]; then
echo "Yes"
else
echo "No"
fi
fi
if [ $2 = "directory" ]; then
if [ -d $1 ]; then
echo "Yes"
else
echo "No"
fi
fi

if [ $2 = "regular" ]; then
if [ -f $1 ]; then
echo "Yes"
else
echo "No"
fi
fi

if [ $2 = "readable" ]; then
if [ -r $1 ]; then
echo "Yes"
else
echo "No"
fi
fi

if [ $2 = "writable" ]; then
if [ -w $1 ]; then
echo "Yes"
else
echo "No"
fi
fi

if [ $2 = "executable" ]; then
if [ -x $1 ]; then
echo "Yes"
else
echo "No"
fi
fi

Check file type

regular_files=0
directory_files=0
for i in `ls $1`
do
if [ -f $1/$i ]; then
let regular_files=$regular_files+1
elif [ -d $1/$i ]; then
let directory_files=$directory_files+1
fi
done
echo "regular files: $regular_files"
echo "directory files: $directory_files"

Search the directory

s=0
cnt=0
for i in `cat $1`
do
let s=$s+1
echo $i
read -e j
if [ $i = $j ]; then
echo "(O)"
let cnt=$cnt+1
else
echo "(X)"
fi
done
echo "$cnt / $s"

Dictation

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

--

--