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
Sendmail retries sending to non-existant users vertigo23 UNIX for Advanced & Expert Users 0 08-10-2007 06:31 PM
Creat a File with a Specific Size aldowsary AIX 3 12-14-2006 11:35 AM
Creat-Crontab dhinesh High Level Programming 2 04-21-2006 07:10 AM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM
how to creat 1 parent to call 3 children zmanultra High Level Programming 1 10-21-2005 04:37 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 04-06-2007
kumarsaravana_s kumarsaravana_s is offline
Registered User
  
 

Join Date: Feb 2007
Location: Bangalore
Posts: 105
How to creat a non-existant file????

Hi,

Everyday i'm supposed to get a file DESC_HYD_DAILY_040620070010.txt.But when this file doesnt showup,i want to create it.What i'm doing is just using the vi editor to create the file manually.

I want this to be put inside a loop,create it automatically everyday.The date portion changes everyday too.So the date should also change dynamically.

file=DESC_HYD_DAILY_040620070010.txt

if [! $file]
create the file
else
echo "the file exists"
if

Any help is appreciated??

Thanks,
Kumar
  #2 (permalink)  
Old 04-06-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Kumar,
Try:

file=DESC_HYD_DAILY_040620070010.txt
touch $file

If the file exists, it will update its last update date.
If the file does not exist, it will create it.
  #3 (permalink)  
Old 04-06-2007
kumarsaravana_s kumarsaravana_s is offline
Registered User
  
 

Join Date: Feb 2007
Location: Bangalore
Posts: 105
Quote:
Originally Posted by Shell_Life
Kumar,
Try:

file=DESC_HYD_DAILY_040620070010.txt
touch $file

If the file exists, it will update its last update date.
If the file does not exist, it will create it.
Thanks for your reply,but it doesnt work...I tried creating the file with yesterdays date

file=DESC_HYD_DAILY_040520070010.txt
touch $file

it creates the file if it doesnt exit,but when i execute it for the second time,it is not changing it to todays late..
  #4 (permalink)  
Old 04-06-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Kumar,
Please issue:
ls -l your_file_name

What date does it show?
  #5 (permalink)  
Old 04-06-2007
kumarsaravana_s kumarsaravana_s is offline
Registered User
  
 

Join Date: Feb 2007
Location: Bangalore
Posts: 105
Quote:
Originally Posted by Shell_Life
Kumar,
Please issue:
ls -l your_file_name

What date does it show?
it is showing yesterdays date 04052007....and todays file hasnt come..so i want to create todays file 04062007...i want this to be done in a loop everyday...
  #6 (permalink)  
Old 04-06-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Kumar,
What you are saying is that the "touch" command is not working?

I will repeat again what I said about the "touch" command:
If the file exists, it will update its last update date.
If the file does not exist, it will create it.

I don't know what else to tell you.
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 03:21 PM.


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