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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File is not empty? lesstjm Shell Programming and Scripting 7 07-12-2007 07:21 AM
File created time yakyaj UNIX for Advanced & Expert Users 6 03-23-2007 05:20 AM
file was created before 15 days ago. YoungBlood UNIX for Dummies Questions & Answers 1 03-02-2007 09:23 AM
want to cat the latest log file created vkandati UNIX for Dummies Questions & Answers 1 03-08-2005 02:13 PM
File Created On attribute dpalmer UNIX for Dummies Questions & Answers 1 09-16-2001 07:44 AM

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

Join Date: Apr 2007
Posts: 36
How to empty a file(already created)

What is the command to empty an already existing file.

please provide me.i used Touch cmd to empty the file.but it changing the time only.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-04-2007
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,199
Code:
> file
or
Code:
: > file
Reply With Quote
  #3 (permalink)  
Old 07-04-2007
Registered User
 

Join Date: Apr 2007
Posts: 36
i need to empty a file which is already existing.
Reply With Quote
  #4 (permalink)  
Old 07-04-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by laknar View Post
i need to empty a file which is already existing.
cat </dev/null >file
Reply With Quote
  #5 (permalink)  
Old 07-04-2007
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,199
Quote:
Originally Posted by laknar View Post
i need to empty a file which is already existing.
The command works also for an existing file :
Code:
$ ls -l my_file
-rw-r--r-- 1 Jean-Pierre Aucun 8943 Jul  4 18:55 my_file
$ > my_file
$ ls -l my_file
-rw-r--r-- 1 Jean-Pierre Aucun 0 Jul  4 18:56 my_file
$
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:28 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