Commit 53bd39dc authored by Ayush's avatar Ayush

First Project

parents
File added
File added
read N
sum=0
temp=0
for (( i=1 ; i<=$N ; i++)); do
temp=$((i*i))
sum=$((sum+temp))
done
echo $sum
(find $1 -mindepth 1 -maxdepth 1 -type d) | wc -l
#!/usr/bin/env bash
grep 5 q3_in.txt | sort > q3_out.txt
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env bash
file=`sort -n q4_in.txt`
i=0
sum=0
for var in $file; do
sum=$((sum+var))
i=$((i+1))
done
rem=$((i%2))
n=0
#echo "rem: $rem"
if [ $rem -eq 0 ]
then
#echo "even"
for var in $file; do
n=$((n+1))
if [ $n -eq $((i/2)) ]
then
median=$var
fi
done
else
#echo "odd"
for var in $file; do
n=$((n+1))
if [ $n -eq $(((i/2)+1)) ]
then
median=$var
fi
done
fi
#echo "i: $i"
#echo "sum: $sum"
echo "mean: $((sum/i))"
echo "median: $median"
\ No newline at end of file
10
40
70
3
2
203050029 solve question q2
203050113 solve question q1
203050111 solve question q3
203050035 solve question q4
References-
https://devhints.io/bashhttps://linuxconfig.org/bash-scripting-tutorial-for-beginnershttps://ubuntu-maryland.org/presentations/reference_bash-cheat.pdf
https://devhints.io/bash
https://linuxconfig.org/bash-scripting-tutorial-for-beginners
https://ubuntu-maryland.org/presentations/reference_bash-cheat.pdf
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