The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help needed in using case statement jisha Shell Programming and Scripting 0 01-16-2008 04:33 AM
more elegant way for conditional statement needed candyflip2000 Shell Programming and Scripting 3 05-18-2006 08:52 AM
Passing argument from one script to other lloydnwo Shell Programming and Scripting 3 10-27-2005 03:06 PM
pass argument to a filename jpprial UNIX for Dummies Questions & Answers 1 09-03-2001 04:12 PM
Passing argument to awk script AkumaTay UNIX for Dummies Questions & Answers 1 08-03-2001 12:12 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-01-2009
I-1 I-1 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 26
help needed with script that gets a filename as argument (with an if/else statement)

Hi,

I am trying to create a script just to study BASH scripting, but I have some problems.

I need to create a script that gets a filename as an argument. The script should behave as follows:
• If the given file name already exists, inform the user and quit.
• If the given file name does not exist, create an empty file by that name and inform the user.

This is my start:


Code:
#!/bin/sh
echo "type in a filename:"
read $FILENAME

if 

....

else

#filename that does not exist is created
echo "The filename $FILENAME does not exist, creating empty file $FILENAME"
touch $FILENAME

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On




All times are GMT -4. The time now is 09:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0