944,050 Members | Top Members by Rank

Ad:
Feb 20th, 2005
0

Linux Shell Script

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jopdukes is offline Offline
1 posts
since Feb 2005
Feb 21st, 2005
0

Re: Linux Shell Script

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.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Apr 29th, 2005
0

Re: Linux Shell Script

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ShaneUniStudent is offline Offline
3 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Shell Scripting problem and related awk issues
Next Thread in Shell Scripting Forum Timeline: what's the meaning of " ${1:-} "?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC