Commit 541c81d9 authored by Snehlata's avatar Snehlata

we did our best

 Please enter the commit message for your changes. Lines starting
parents
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
#!/bin/bash
a="$1"
s=0
x=0
for ((i=1;i<=$((a));i++)); do
x=$((i*i))
s=$((s+x))
done
echo "$s"
File added
File added
File added
#!/bin/sh
path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$path"
cd "$1"
ls -l | grep -c ^d
File added
File added
File added
File added
File added
#! /bin/bash
#input from q3_in.txt after sorting output in q3_in.txt
grep "[5]" q3_in.txt | sort >q3_out.txt
This diff is collapsed.
This diff is collapsed.
File added
File added
File added
#! /bin/bash
filename='q4_in.txt'
while read line; do
read -a num <<< $line
done < $filename
tot=${#num[@]}
sum=0
for i in "${num[@]}"; do
#sum='echo $(printf "%.2f" $((sum+i)))
#sum='echo "$((sum+i)" | bc -l' printf '%0.3f' "$sum"
sum=$((sum+i))
done
mean=$((sum/tot))
echo $mean
for ((i = 0; i<tot; i++)) do
for((j = 0; j<tot-i-1; j++)) do
if [ ${num[j]} -gt ${num[$((j+1))]} ]
then
temp=${num[j]}
num[$j]=${num[$((j+1))]}
num[$((j+1))]=$temp
fi
done
done
if [ $((tot%2)) -eq 0 ]
then
ind=$((tot/2))
a=${num[ind]}
b=${num[$((ind-1))]}
echo $((((a+b))/2))
else
echo ${num[$((tot/2))]}
fi
Contributions:
CSE Git usernames:
CSE GIT username snehlatayadav
q1: Pooja Gayakwad (203050076)
q2: Sanjna Mohan (20305R006)
q3: Snehlata Tadav (203050075)
q4: Manjusree M P (203059007)
References:
https://stackoverflow.com/questions/2564634/convert-absolute-path-into-relative-path-given-a-current-directory-using-bash
https://stackoverflow.com/questions/24112727/relative-paths-based-on-file-location-instead-of-current-working-directory
https://unix.stackexchange.com/questions/273341/obtain-script-current-directory-so-that-i-can-do-include-files-without-relative
https://code-maven.com/bash-shell-relative-path#:~:text=It%20needs%20to%20find%20its,the%20page%20about%20absolute%20path.&text=The%20point%20is%2C%20however%2C%20that,down%20the%20%22data%22%20direcotry.
https://stackoverflow.com/questions/17648033/counting-number-of-directories-in-a-specific-directory
https://www.linuxquestions.org/questions/programming-9/shell-script-help-how-to-pass-a-directory-path-to-the-script-668752/
https://shapeshed.com/unix-wc/#:~:text=To%20count%20the%20number%20of%20folders%20and%20files%20in%20a,wc%20to%20give%20a%20count.
https://stackoverflow.com/questions/24341686/passing-a-path-as-an-argument-to-a-shell-script
https://ubuntu-maryland.org/presentations/reference_bash-cheat.pdf
https://linuxconfig.org/bash-scripting-tutorial-for-beginners#h7-script-execution
https://wiki.bash-hackers.org/syntax/shellvars#special_parameters_and_shell_variables
https://devhints.io/bash
https://linuxhint.com/read_file_line_by_line_bash/
https://linuxhint.com/bash_split_examples/
https://www.geeksforgeeks.org/sorting-the-array-in-bash-using-bubble-sort/
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