Commit 04fc0eee authored by Keshav Agarwal's avatar Keshav Agarwal

CS 699 Week 2

parents
#!/bin/bash
sum=0
if [ $# != '1' ]
then
echo 'Error: Invalid arguments'
exit
fi
for((i=1;i<= $1;i++))
do
sum=$(($sum+$i*$i))
done
echo $sum
\ No newline at end of file
#!/bin/bash
#echo "Script param: $1";
#echo "=============================";
#echo "pwd:";
#pwd;
#echo "=============================";
#echo "find d1 -maxdepth 1 -type d";
#find $1 -maxdepth 1 -type d;
#echo "=============================";
#echo "find d1 -maxdepth 1 -type d | wc -l";
#find $1 -maxdepth 1 -type d | wc -l;
ls -l $1 | grep -c ^d;
#echo "=============================";
#count = $(find $1 -maxdepth 1 -type d | wc -l);
#count = count - 1;
#echo "$count";
#!/bin/bash
sort q3_in.txt -n |grep "5" > q3_out.txt
This diff is collapsed.
#!/bin/bash
sums=0
counts=0
arr=()
sort q4_in.txt > tem.txt
while read p
do
arr[counts]=$p
counts=`expr $counts + 1`
sums=`expr $sums + $p`
done < tem.txt
echo `expr $sums / $counts`
rem=$(( $counts % 2 ))
if [ $rem -eq 0 ]
then
echo "$(( ( arr[$(($counts/2))] + arr[$(($counts/2-1))] ) / 2 ))"
else
echo "${arr[$counts /2]}"
fi
rm tem.txt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment