Linux Shell Script

Reply

Join Date: Feb 2005
Posts: 1
Reputation: jopdukes is an unknown quantity at this point 
Solved Threads: 0
jopdukes jopdukes is offline Offline
Newbie Poster

Linux Shell Script

 
0
  #1
Feb 20th, 2005
I have been given the task of writing a small shell script which does the following:

It takes two arguments: the first argument is the name of the original file and the second argument is the new name for the file. If a user does not provide two arguments, a usage message will appear on the screen and the script will exit. The script should check to see if the new name already exists. If the name does already exist the script should prompt the user for a decision about whether the file should be overwritten.


I know it is quite lengthy but any help will be appreciated.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,040
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Linux Shell Script

 
0
  #2
Feb 21st, 2005
Where exactly are you having the problem? Have you attempted to write the code yourself? We will help you debug, diagnose, or give you ideas, but we have a policy where we won't write your code for you.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 3
Reputation: ShaneUniStudent is an unknown quantity at this point 
Solved Threads: 0
ShaneUniStudent ShaneUniStudent is offline Offline
Newbie Poster

Re: Linux Shell Script

 
0
  #3
Apr 29th, 2005
Hey buddy, what youre trying to do can easily be implement with a TEST condition at the start of your shell script. For example:

#!/bin/bash

echo -e "Reading input file name $1 from user..."
echo -e "Reading new file name $2 from user.."

if [ -r $1 ] #checks if files exists and is readable
then
#perform operations on file
else
echo -e "File Doesnt Exist!!!"
fi

This should help you out, giving you the basic idea that you can now employ with the new file.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC