The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Have a shell script check for a file to exist before processing another file heprox Shell Programming and Scripting 3 11-14-2006 03:26 AM
*Error: file </tmp/srw25108193> does not exist cgege HP-UX 0 04-10-2006 03:18 AM
how to check if directory/file exist using c/c++ steven88 High Level Programming 2 01-03-2006 02:55 AM
how to check if directory/file exist using c/c++ steven88 Shell Programming and Scripting 1 01-02-2006 10:45 PM
how to check if the file exist or not? gusla UNIX for Dummies Questions & Answers 3 03-27-2002 10:56 PM

Closed Thread
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
  #1 (permalink)  
Old 05-28-2008
din_annauniv din_annauniv is offline
Registered User
  
 

Join Date: May 2008
Posts: 14
If file not exist create a new one

i want a script to check whether the file name exits or not if not it has to create a new one
  #2 (permalink)  
Old 05-28-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
What did you try so far..??
  #3 (permalink)  
Old 05-28-2008
siba.s.nayak siba.s.nayak is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 164
test -e fff.txt || touch fff.txt

It will create an empty file fff.txt if it doesn't exist.

Other thing when you use cat > <file> It also create the file if is not present and if it present it over writes the contents.
  #4 (permalink)  
Old 05-28-2008
Dave Miller's Avatar
Dave Miller Dave Miller is offline
Registered User
  
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 151
This sounds like homework.

I would also like to know what you tried so far.

For what it's worth, the answer is in siba.s.nayak's post, although it is a lot less complicated than what siba indicated.
Closed Thread

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 10:54 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