Linux / UNIX Tech Support Forum
This is a discussion on UNIX Shell Programming Assistance? within the Shell scripting forums, part of the Development/Scripting category; Tough UNIX shell programming assignment. Suggestions? Anyone want to show off there superior UNIX expertise? "Prepare a shell program that ...
Register free or login to your account to remove all advertisements.
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
Thread Tools | Display Modes |
|
|||
|
Tough UNIX shell programming assignment. Suggestions? Anyone want to show off there superior UNIX expertise?
"Prepare a shell program that accepts no less than one argument or more than nine arguments. Each of the arguments must be checked to determine if it is a file. If it is not a file, display an error message for each argument that is not a file, redirecting the message to a temporary file and excluding it from the list of arguments used to produce the final output. Each acceptable file then outputs (1) "This file named, (file name here) contains: ", (2) cat|more|pg the file, and (3) display a blank line, a line with 15 underscores, and another blank line. After all the good files are generated, take the information that you redirected to the temporary file and output it to the screen using (1) a line that says "These are entries that are not files: ", and (2) cat the temporary file." Thanks! |
|
|||
|
Okay,
I figured out how to check to see if an argument is a file: -------------------------------------------------------------- #!/bin/sh # Check to see if an argument is a file or not if [ -f $* ] then echo "This is a file" else echo "This is not a file!" fi -------------------------------------------------------------- And I figured out how to write the program to accept no less than one argument or more than nine arguments: -------------------------------------------------------------- if [ $# -lt 1 ] && [ -gt 9 ] then echo "Error in $0 - Invalid Argument Count" echo "Syntax: $0 input_file output_file" exit fi -------------------------------------------------------------- The problem now is how to do the rest and then somehow put it into nested loops. Thanks! |
![]() |
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| UNIX Shell Scripting Books | chimu | Shell scripting | 5 | 8th July 2009 10:59 AM |
| What is UNIX / Linux Shell? | gr8linux | Shell scripting | 2 | 17th June 2009 07:23 AM |
| UNIX shell script | AAgarwal8 | Shell scripting | 4 | 8th September 2008 07:36 PM |
| unix shell on windows xp | chiku | Solaris/OpenSolaris | 4 | 7th March 2008 03:17 PM |
| Linux UNIX SFTP in a Shell Script | Nishanthhampali | Shell scripting | 1 | 30th January 2008 01:16 PM |