Sponsored Content
Homework and Emergencies Homework & Coursework Questions Need answers for these shell programs..... Post 302790899 by sandeep148 on Sunday 7th of April 2013 07:53:29 AM
Old 04-07-2013
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.

6. 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.

7. Write a shell script to count the frequency of semi colons(Smilie 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.

8. 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

9. 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

10. 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.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

different shell programs,processes

Hi, why do we have 3 types of shell programs. I read that the k-shell is supposed to be the latest replacement of the Bourne shell with additional features. But why call it K-shell when one can call it as a different version of Bourne shell say bourne2. what do we have the C shell for? Is... (1 Reply)
Discussion started by: ramyar
1 Replies

2. Shell Programming and Scripting

shell programs

how to write pipe for finding out the login names and login time of the users whose login name begins with p. (1 Reply)
Discussion started by: rameshparsa
1 Replies

3. Shell Programming and Scripting

shell programs required

please help iam a student and i have been asked to submit shell programs . i have given a listing and can u direct me as to where i can find the programs or if anyone could be kind enough to solvbe them for me and post it here pls shell program to implement IPC to implement parent child... (1 Reply)
Discussion started by: ushasathyam2006
1 Replies

4. UNIX for Dummies Questions & Answers

Are programs like sys_open( ) ,sys_read( ) et al examples of system level programs ?

Are the programs written on schedulers ,thread library , process management, memory management, et al called systems programs ? How are they different from the programs that implement functions like open() , printf() , scanf() , read() .. they have a prefix sys_open, sys_close, sys_read etc , right... (1 Reply)
Discussion started by: vishwamitra
1 Replies

5. UNIX for Dummies Questions & Answers

Few shell programs advice

Hy i have some tasks to do in school but i'm having problems with it,so could you help me out? :) first there is a task where i have to find a running program on the system and kill it, then repeat that every 5 minutes. The name of the process is given with an argument. I have done this so far,... (1 Reply)
Discussion started by: petel1
1 Replies

6. Shell Programming and Scripting

Interactive shell - Give answers to shell

Hi, I have a script that calles some other scripts. Those scripts are expecting some inputs. Right no I am typing manually. But now the number of questions from other scripts are too much and I want to give asnwers autimatically. example. Other scripts gives me 2 options 1) joom... (2 Replies)
Discussion started by: microsim
2 Replies

7. Homework & Coursework Questions

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... (1 Reply)
Discussion started by: sandeep148
1 Replies

8. Shell Programming and Scripting

Select answers from multiple questions using shell script

I have a text file in this format Some lines.... Question no: 1 The question? A. Answer 1 B. Answer 2 C. Answer 3 D. Answer 4 Answer:B Some lines.... Question no: 2 The question? (choose 2) (10 Replies)
Discussion started by: zorrox
10 Replies

9. UNIX for Dummies Questions & Answers

Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys, Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries. However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by... (2 Replies)
Discussion started by: syncmaster
2 Replies
qmail-pw2u(8)						      System Manager's Manual						     qmail-pw2u(8)

NAME
qmail-pw2u - build address assignments from a passwd file SYNOPSIS
qmail-pw2u [ -/ohHuUC ] [ -cchar ] DESCRIPTION
qmail-pw2u reads a V7-format passwd file from standard input and prints a qmail-users-format assignment file. A V7-format passwd file is a series of lines. Each line has the format user:password:uid:gid:gecos:home:shell where user is an account name, uid and gid are the user id and group id of that account, and home is the account's home directory. pass- word, gecos, and shell are ignored by qmail-pw2u. If you put the output of qmail-pw2u into /var/lib/qmail/users/assign, and then run qmail-newu, qmail-lspawn will obey the assignments printed by qmail-pw2u. WARNING: After changing any users, uids, gids, or home directories in your passwd file, you must run qmail-pw2u and qmail-newu again if you want qmail-lspawn to see the changes. RULES
By default, qmail-pw2u follows the same rules as qmail-getpw. It skips user if (1) uid is zero, (2) home does not exist, (3) user does not own home, or (4) user contains uppercase letters. It then gives each remaining user control over the basic user address and all addresses of the form user-anything. A catch-all user, alias, controls all other addresses. You may change these rules by setting up files in /var/lib/qmail/users: include Allowed users, one per line. If include exists, and user is not listed in include, user is ignored. exclude Ignored users, one per line. If exclude exists, and user is listed in exclude, user is ignored. mailnames Replacement names for users. Each line has the form user:mailname1:mailname2:... The addresses mailname1 and mailname1-ext and mailname2 and so on will be delivered to user. WARNING: The addresses user and user-ext will not be delivered to user unless user is listed as one of the mailnames. A line in mailnames is silently ignored if the user does not exist. subusers Extra addresses. Each line has the form sub:user:pre: sub will be handled by home/.qmail-pre, where home is user's home directory; sub-ext will be handled by home/.qmail-pre-ext. append Extra assignments, printed at the end of qmail-pw2u's output. OPTIONS
-o (Default.) Skip user if home does not exist (or is not visible to qmail-pw2u). Skip user if home is not owned by user. -h Stop if home does not exist. This is appropriate if every user is supposed to have a home directory. Skip user if home is not owned by user. -H Do not check the existence or ownership of home. -U (Default.) Skip user if there are any uppercase letters in user. -u Allow uppercase letters in user. -cchar Use char as the user-extension delimiter in place of -. -C Disable the user-extension mechanism. -/ Use home/.qmail-/... instead of home/.qmail-... SEE ALSO
qmail-users(5), qmail-lspawn(8), qmail-newu(8), qmail-getpw(8) qmail-pw2u(8)
All times are GMT -4. The time now is 04:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy