0% found this document useful (0 votes)
12 views1 page

VI Semester Linux Shell Scripts List

The document outlines a program list for a VI Semester Linux Shell Programming course for the 2020-21 academic year. It includes 15 programming assignments where students will write shell scripts to perform various math calculations, check conditions, manipulate strings, and perform file operations. The assignments increase in complexity and cover topics like calculations, control flow, functions, file I/O and time-based execution.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

VI Semester Linux Shell Scripts List

The document outlines a program list for a VI Semester Linux Shell Programming course for the 2020-21 academic year. It includes 15 programming assignments where students will write shell scripts to perform various math calculations, check conditions, manipulate strings, and perform file operations. The assignments increase in complexity and cover topics like calculations, control flow, functions, file I/O and time-based execution.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VI Semester Linux Shell Programming

Program List for the Academic Year 2020-21

1. Write a shell script to find area of a circle


2. Write a shell script to find given number is even or odd
3. Write a shell script to make a menu driven calculator using case
4. Write a shell script to find the greatest of three numbers
5. Write a shell script to compute mean and standard deviation of three numbers
6. Write a shell script to find sum of all digits from a given number
7. Write a shell script to find reverse of a number
8. Write a shell script to find prime numbers up to a given number
9. Write a shell script to find n Fibonacci numbers
[Link] a shell script to check whether a given number is Armstrong or not
[Link] a shell script to reverse a string and check whether a given string is
palindrome or not
[Link] a shell script to count no of line, words and characters of an input file
[Link] a shell script find the factorial of a given number
[Link] employee Basic Pay is input through keyboard where DA is 40% of basic pay
and HRA is 20% of basic pay. Write a shell script to calculate gross salary, Gross
Salary =Basic Pay + DA + HRA
[Link] a shell script which whenever gets executed displays the message Good
Morning/Good afternoon /Good Evening depending on the time it gets executed

Common questions

Powered by AI

Writing a shell script to calculate mean and standard deviation requires not only programming knowledge but also conceptual understanding of these statistical measures. Mean is the average value, which involves summing all the numbers and dividing by their count. The standard deviation measures variability and involves computing squared differences from the mean and taking the square root of the average of these differences. This understanding is crucial because errors in calculations can lead to misinterpretation of data statistics, affecting decision-making processes .

Recursion in a shell script for computing factorial involves a function calling itself with decremented values until it reaches a base case of one. The factorial of a number n (denoted n!) is the product of all positive integers up to n. By implementing a recursive structure, the script calls itself multiply with decremented input until it multiplies to 1, effectively using recursive depth to calculate factorial. Recursion provides a compact and elegant solution, challenging in shell scripting due to its typical linear execution model but is feasible with stack frame management via functions .

To reverse a number in a shell script, constructs such as loops and modulus operators are employed. Modulus is used to extract digits, and loops reconstruct the number in reverse order. Challenges include handling negative numbers, leading zeros in reversals, and ensuring correct datatype handling during operations. Additionally, careful consideration of edge cases, like single-digit numbers or zero, is needed to ensure the script's effectiveness and efficiency .

Conditional statements in a shell script to calculate gross salary are necessary to account for variations in pay structures such as varying percentages for DA or HRA based on the employee's position, experience, or location. These conditions ensure accuracy and flexibility in the script to accommodate different organizational pay setups rather than a one-size-fits-all calculation. By using conditionals, the script can dynamically calculate correct gross salaries under different scenarios, enhancing its applicability across diverse payroll configurations .

Challenges in creating a shell script to find the greatest of three numbers include accurately comparing each number and handling inputs that are non-numeric or equal. These can be addressed by using robust conditional statements (if-else or case structures) to compare numbers, as well as implementing input validations to ensure proper data types are provided. Effective error handling can prompt the user to re-enter the numbers if inputs are invalid .

Writing a shell script to check if a number is an Armstrong number requires understanding the mathematical principle behind Armstrong numbers. The script must retrieve each digit of the number, compute the power of digits according to the number's total digits, and then sum these results. Analyzing the logical flow needed to separate digits, apply mathematical operations, and perform iterative sums demonstrates advanced computational reasoning skills. Furthermore, it involves conditions to compare sums with the original number, highlighting logical skills .

A shell script that displays messages based on execution time leverages time-checking functions and conditional statements. First, the script retrieves the current time using date commands, evaluates time segments, and then uses if-else or case statements to output 'Good Morning,' 'Good Afternoon,' or 'Good Evening' accordingly. Features like pattern matching and time-reading utilities in shell scripts facilitate dynamic output, helping to construct responsive programs based on temporal data .

Input validation is critical in shell scripts for numerical calculations to ensure data integrity and accurate outputs. In the case of checking even or odd numbers, validating ensures that the input is an integer, guarding against erroneous user input that could lead to incorrect outputs or runtime errors. Validations help maintain the script's robustness, providing feedback or re-prompting the user if data is outside expected parameters .

The complexity of a shell script for reversing a string and checking for palindromes is influenced by string handling techniques and comparison operations. Reversing a string involves iteratively swapping or reconstructing the string from its end to start, which can become complex with longer or complex string structures. Checking for palindromes extends this by having to compare the original string to its reversed version. Efficient manipulation and comparison logic in the script are crucial, and scripting languages' handling of string operations directly impacts complexity .

A menu-driven calculator in shell scripting enhances user experience by providing a structured interface for performing arithmetic operations. It simplifies execution by guiding users through options rather than requiring command-line instructions for each calculation. Programming constructs like case statements enable its functionality by switching control based on user menu selection, paired with input validation and looping constructs to allow multiple actions without restarting the script. This approach fosters usability and modularity, significantly improving interaction .

You might also like