Commit 16d88430 authored by Kunal's avatar Kunal

added outlab

parent 93423a30
#!/bin/bash
num=$(($1*($1+1)*(2*$1+1)))
num=$((num/6))
echo "${num}"
#!/bin/bash
ls "$1" -l | grep -c ^d
#!/bin/bash
grep '5' q3_in.txt > q3_out.txt
sort -n q3_out.txt > tmp && mv tmp q3_out.txt
This diff is collapsed.
#!/bin/bash
input="q4_in.txt"
filename='q4_in.txt'
n=0
S=0
read line < $input
for i in $line; do
n=$((n+1))
S=$((S+$i))
#echo "$S $n"
#statements
done
printf %.2f\\n "$((1000 * S/n ))e-3"
#S="${S}.0"
if (( n%2==1 )) ; then
#statements
Median=$(((n+1)/2))
#echo "$Median is median"
tr ' ' '\n' <<<"$line" | sort -n | paste -sd' ' - > output.txt
read line < "output.txt"
num=0
for i in $line; do
num=$((num+1))
if [[ $num -eq $Median ]]; then
ans=$i
#statements
fi
#echo "$S $n"
#statements
done
echo "$ans"
fi
if (( n%2==0 )); then
#statements
Median1=$(((n+2)/2))
Median2=$((n/2))
#echo "$Median2 $Median1"
tr ' ' '\n' <<<"$line" | sort -n | paste -sd' ' - > output.txt
read line < "output.txt"
num=0
for i in $line; do
num=$((num+1))
if [[ $num -eq $Median1 ]]; then
ans1=$i
#statements
fi
if [[ $num -eq $Median2 ]]; then
ans2=$i
#statements
fi
#echo "$S $n"
#statements
done
printf %.2f\\n "$((1000 * (ans1+ans2)/2 ))e-3"
#final=$(((ans1+ans2)/2))
#echo "$final"
fi
\ No newline at end of file
Contribution:
Kunal Verma(203050121 - kunalverma) - Q1
Nimesh Agrawal(203050049 - nimesh) - Q2
Mallela Niteesh Kumar(203050065 - niteesh) - Q3
Shubhranshu Maurya(203050096 - shubhranshu) - Q4
Git Link:
References:
1) https://learnxinyminutes.com/docs/bash/
2) https://www.cyberciti.biz/faq/unix-howto-read-line-by-line-from-file/
3) https://unix.stackexchange.com/questions/264280/is-it-possible-to-get-a-decimal-output-from-doing-division-in-bash
Username For Git Lab : Nimesh , kunalverma , niteesh , shubhranshu
Nimesh has Uploded on Git
Git repo https://nimesh@git.cse.iitb.ac.in/nimesh/Outlab1.git
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