Need answers for these shell programs.....

  1. Write a shell script to print the file names of all files having .txt extension of a given directory after converting to uppercase letters. The input (directory name) should be given as command line argument. The script will also check whether sufficient arguments are passed or not and whether the argument is a directory or not. In case of invalid input, proper message should be displayed.

  2. Write a script that would print any one of the following message along with the username according to the system time:
    Good Morning, between 12 AM and 12 PM.
    Good Afternoon, between 12PM and 4 PM
    Good Evening, after 4 PM

  3. Write a shell script - compare.sh
    It will take two string arguments from the user, compare them and give the output �Both are same� or �Both are different� based on whether they are same or not. If input string is null, error message should be given.
    If user enters less or more number of arguments, an error should be thrown

  4. Write a script which accept a number from command line and check whether it is prime or not. If it is prime number then store this number into prime.txt file otherwise store into notprime.txt file.
    If user enters less or more number of arguments, an error should be thrown.

  5. Write a shell script - reverse.sh
    It will take a line as argument from the user, and display it in reverse order. If input string is null, error message should be given.
    If user enters less or more number of arguments, an error should be thrown

Ex :
Input : This is Unix.
Output : Unix is This.

  1. Write a shell script that prints the total number of users having a given file in their home directory. The input filename should be supplied as command line argument.

  2. Write a shell script to count the frequency of semi colons( in a given file. The input file should be given as command line argument. The script will check whether sufficient arguments are there or not and whether the argument is a file or not while the script is executed. In case of invalid input , proper message should be displayed.

  3. Use awk for displaying first n numbers in Fibonacci series where n is supplied as command line argument.
    Note: Fibonacci series of numbers are 0 and 1, and each remaining number is the sum of the previous two. For e.g. first 5 numbers in Fibonacci series are 0, 1, 1, 2, 3

  4. Write a shell script to display the four letter words in a given file. The script will also print the count of such words. The input file should be given as command line argument. The script will check whether sufficient arguments are there or not and whether the argument is a file or not while the script is executed. In case of invalid input, proper message should be displayed.
    NOTE: The output should display the word only once although it may occur in the file more than once. Total count should be also the count of the distinct words.

e.g If the content of the given file is as folows----------------
There are three bags.
This is a blue bag.
My blue bags are full.

The output should be as----------------------
bags
This
blue
full
Count of four letter words is: 4

  1. Write a shell script to display the longest line in a given file. It will also display the number of words in that line. The input file should be given as command line argument. The script will check whether sufficient arguments are there or not and whether the argument is a file or not while the script is executed. In case of invalid input, proper message should be displayed.

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.