The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Removing empty folders using 'find' deTTo UNIX for Dummies Questions & Answers 5 04-21-2008 06:24 PM
Removing empty folders using the "find" command biot UNIX for Dummies Questions & Answers 3 03-25-2008 06:43 PM
File is not empty? lesstjm Shell Programming and Scripting 7 07-12-2007 07:21 AM
Removing empty spaces and adding commas jazz High Level Programming 4 11-13-2006 05:54 AM
empty file in hp-ux Mizi UNIX for Advanced & Expert Users 2 08-09-2006 03:29 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2007
Registered User
 

Join Date: Jun 2002
Posts: 36
How to empty a file without removing it.

I used to be able to do the following command on HP while largefile was being written to.

> echo " " > largefile

When I try the same on Solaris I get a message that the file already exists.

Is there a parameter that I need to setup in my env ?

Thanks in advance

Last edited by jxh461; 05-30-2007 at 06:12 PM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-30-2007
Shell_Life's Avatar
Unix/Informix/4GL/SQL
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Jxh461,
There is an option in the "set" command that controls the truncation of files.
The following does not allow files to be truncated:
Code:
set -o noclobber
Reply With Quote
  #3 (permalink)  
Old 05-30-2007
Registered User
 

Join Date: Jun 2002
Posts: 36
Thanks for that info Shell. However, I am not sure if that is the cause of my problem. In any case how would I unset it if it were ?
Reply With Quote
  #4 (permalink)  
Old 05-30-2007
Registered User
 

Join Date: May 2007
Posts: 13
try this

>largefile
Reply With Quote
  #5 (permalink)  
Old 05-30-2007
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Code:
echo '' >| largefile
# OR more simply
>| largefile
Reply With Quote
  #6 (permalink)  
Old 05-30-2007
Registered User
 

Join Date: Jan 2005
Posts: 212
cat /dev/null > largefile
Reply With Quote
  #7 (permalink)  
Old 05-30-2007
Registered User
 

Join Date: Jan 2005
Posts: 212
set +o noclobber.


Then any of the above commands will work.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0