nixCraft Linux / UNIX / Shell Scripting Forum

nixCraft

Linux / UNIX Tech Support Forum

UNIX Shell Programming Assistance?

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.

Go Back   nixCraft Linux / UNIX / Shell Scripting Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

Thread Tools Display Modes
  #1 (permalink)  
Old 22nd November 2009, 08:06 PM
Junior Member
 
Join Date: Nov 2009
OS: Debian
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
DamienCurr is on a distinguished road
Default UNIX Shell Programming Assistance?

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!
Reply With Quote
  #2 (permalink)  
Old 24th November 2009, 07:58 PM
jaysunn's Avatar
Contributors
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Scripting language: bourne again shell
Posts: 767
Thanks: 108
Thanked 104 Times in 95 Posts
Rep Power: 14
jaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud of
Default

Please show us what you have so far. I am sure that we can assist you from there.

Jaysunn
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
  #3 (permalink)  
Old 26th November 2009, 10:40 PM
Junior Member
 
Join Date: Nov 2009
OS: Debian
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
DamienCurr is on a distinguished road
Default

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!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

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


All times are GMT +5.5. The time now is 08:59 PM.


Powered by vBulletin® Version 3.8.6 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40