#!/bin/bash
echo "How many number you want to enter : "
read no
echo
for i in `seq $no`
do
echo -n "Enter no $i : "
read num
nos[$i]=$num
done
echo "Entered Numbers are: ${nos[*]}"
echo
max=`printf '%s\n' "${nos[@]}" | awk '$1 > m || NR == 1 { m = $1
} END { print m }'`
echo "Max is: "$max
avg=`printf '%s\n' "${nos[@]}" | awk 'NR == 1 { s=0 } { s+=$1;}
END { print s/NR}'`
echo "Average is: "$avg
sum1=`printf '%s\n' "${nos[@]}" | awk 'NR == 1 { s=0 } { s+=$1;}
END { print s}'`
echo "Sum is: "$sum1
if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)
using bash do the following script 1. Enter a list 2. Find the sum of the...
I need help with this. 1. In a bash shell script, what are the required elements of an "if" control structure? 2. In a bash shell script, what are the optional elements of an "if" control structure? 3. In a bash shell script, what are the required elements of a "while" control structure? 4. What is the difference between a shell variable and environment variable? Which one is considered local and which is considered global? 5. List the four kinds...
How do I write a bash script that uses the 'egrep' command to list files containing either 'a' followed by 'g' or 'g' followed by 'a' (possibly with characters in between)?
1. Install the supplied bash script on the Kali Linux VM BASH filename :ipLAN In text editor looks like this #!/bin/bash is_alive_ping() { ping -c 1 $1 >/dev/null 2 >&1 [ $? -eq 0 ] && echo Node with IP: $1 is UP. } for i in 192.168.1.{1..255} do is_alive_ping $1 & disown done QUESTION: Install the supplied bash script on the Kali Linux VM **NOte how do i install the above script in kali ,when i am...
Please write a bash script for the following two questions, thank you. Write a shell script “6-1.sh” to calculate the exponentiation using while loop. This script needs to take two inputs like “6-1.sh a b”, and outputs the result of “ab”. Note: You need to implement it, DO NOT use the exponentiation operation provided by the Linux. Write a shell script “6-2.sh” to calculate the factorial of a number using while loop. This script needs to take one input...
Write a bash shell script to print the number of command line arguments and list of command line arguments 3. 12]
Using bash script write a function named join_with that will join the positional parameters with a character. The function would work like this: join_with "," 1 2 3 4 5 1,2,3,4,5 join_with "-" 12 34 56 78 12-34-56-78 join_with ":" {a..z} a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z
Exercise 1 - Create a List to Sum Values Write a python script that sums the values in a list called add_list that contains the following values: (10, 2, -4, 8). Make sure you include a for loop when iterating through the list to sum the values. Take screenshots of the code and output. Exercise 2 – Create a Dictionary Write a python script that prints a dictionary where the key numbers are 1, 2, 3, 4, and 5 and...
Problem 4: Write a Bash script that removes all zero length ordinary files in the directory (including those in the sub-directories at all levels) passed as an optional argument. If you do not specify the directory argument, the script uses the current working directory as the default argument. This problem is for practicing bash programming skills. Though there is an easier way to achieve the goal with the find command, the find command is not allowed to appear in your...
Write a script using bash that accepts three arguments from the user, then prints out the following: The name of the script The value of each argument