User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 391,914 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,720 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 10580 | Replies: 2
Reply
Join Date: Feb 2005
Posts: 1
Reputation: jopdukes is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jopdukes jopdukes is offline Offline
Newbie Poster

Linux Shell Script

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,879
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 107
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Linux Shell Script

  #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.
Reply With Quote  
Join Date: Apr 2005
Posts: 3
Reputation: ShaneUniStudent is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ShaneUniStudent ShaneUniStudent is offline Offline
Newbie Poster

Re: Linux Shell Script

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

DaniWeb Shell Scripting Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 7:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC