Write a Unix shell script that takes three integers and sorts them from largest to smallest. An example execution is as follows (assume the name of the script is shs): % shs 3 9 4 The order is: 9 4 3 % shs -1 0 3 The order is: 0 -1 -3
PROGRAM
# !/bin/bash
declare num=(3 9 4)
# This will print the array before sorting
echo "Original Numbers in array:"
for (( i=0; i<=2; i++ ))
do
echo ${num[$i]}
done
# Now lets do the Sorting of numbers
for (( i=0; i<=2; i++ ))
do
for (( j=$i; j<=2; j++ ))
do
if [ ${num[$j]} -gt ${num[$i]} ]; then #Just using a
sorting technique with O(n^2)
t=${num[$i]}
num[$i]=${num[$j]}
num[$j]=$t
#swapping the array to get desired result
fi
done
done
# Printing the sorted array
echo -e "\nSorted Numbers in Descending Order
Order:"
for (( i=0; i <= 2; i++ ))
do
echo ${num[$i]}
done
OUTPUT OF THE PROGRAM
This is the running code..It may cause problem due to indentation because i have pasted here from my file.....HOPE YOU WILL FIND THIS HELPFUL... if you have any queries regarding this let me know.
Write a Unix shell script that takes three integers and sorts them from largest to smallest....
In UNIX: write a shell script that takes a FileName.awk as an argument. The shell script then uses that file name to run your awk script and sort the results alphabetically, by student name. data.csv Student,Catehory,Assignment,Score,Possible Chelsey,Homework,H01,90,100 Chelsey,Homework,H02,89,100 Chelsey,Homework,H03,77,100 Chelsey,Homework,H04,80,100 Chelsey,Homework,H05,82,100 Chelsey,Homework,H06,84,100 Chelsey,Homework,H07,86,100 Chelsey,Lab,L01,91,100 Chelsey,Lab,L02,100,100 Chelsey,Lab,L03,100,100
Write a program that inputs ten (10) integers and then sorts them in order from largest to smallest in the programming language called Perl. You do not need to error check the input; you can assume the user enters integers. You can select the sorting algorithm of your choice, but you must implement this algorithm yourself. You cannot use a built-in sorting function. [15 points] Below is an example of a sample program run: Unsorted: 10, 4, 23, 99, 7,...
Python Script format please! 1. Write a script that takes in three integer numbers from the user, calculates, and displays the sum, average, product, smallest, and largest of the numbers input. Important things to note: a. You cannot use the min() or max() functions, you must provide the logic yourself b. The calculated average must be displayed as an integer value (ex. If the sum of the three values is 7, the average displayed should be 2, not 2.3333). Example:...
Unix code problem Write a shell script that does the following : Read many lines of text from the standard input device (keyboard) and copy them to the standard output. Precede each output line with a line number Explain all steps
UNIX QUESTION Write an argument-less shell script "Sum4.csh", which reads four integer values from the keyboard, computes their sum, then displays the sum in expression format. EXAMPLE: % Sum4.csh Enter the first number: 4 Enter the second number: 7 Enter the third number: 3 Enter the fourth number: 11 RESULT: 4 + 7 + 3 + 11 = 25
Unix classes Write a bash script that take in three integer numbers from the command line and print out the sum and the average. Name the script awesum.sh hb1170uxb4:~$ ./awesum.sh 100 200 300 sum: 600 average: 200 hb1170uxb4: ~S
write a program in x86 assembly language that sorts 10 integers entered from the keyboard and displays them in order
Write a script, shuffle.sh which generate. Unique integers and prints them out sorted in ascending order, and then shuffled. The count of the integers is given as a command-line argument. The shell variable RANDOM generates a random integer upon evaluation. In other words echo $ random prints a random integer. You may assume that the command line argument is a valid positive integer. Use only shell constructs and the array structure. In other words, don’t use commands such as sort,...
USING Unix/Linux shell !!!: 1) Write a script (project2.sh) that will take information from a file, and print (user’s choice of printers) identical form letters to each recipient. Either E197, E-199, E-194 printers or to project2.output. Prompt the user for their choice. 2) The script and output file are due: per Moodle timeline. Please upload your fully functioning script (project2.sh) your data file (project2.input) and your output file (project2.output) into Moodle. 3) Requirements of the script. a. You can use...
JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...