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
File is not empty? lesstjm Shell Programming and Scripting 7 07-12-2007 11:21 AM
File created time yakyaj UNIX for Advanced & Expert Users 6 03-23-2007 09:20 AM
file was created before 15 days ago. YoungBlood UNIX for Dummies Questions & Answers 1 03-02-2007 01:23 PM
want to cat the latest log file created vkandati UNIX for Dummies Questions & Answers 1 03-08-2005 06:13 PM
File Created On attribute dpalmer UNIX for Dummies Questions & Answers 1 09-16-2001 11:44 AM

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 07-04-2007
laknar laknar is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 55
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.
  #2 (permalink)  
Old 07-04-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,423
Code:
> file
or
Code:
: > file
  #3 (permalink)  
Old 07-04-2007
laknar laknar is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 55
i need to empty a file which is already existing.
  #4 (permalink)  
Old 07-04-2007
porter porter is offline Forum Advisor  
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
  #5 (permalink)  
Old 07-04-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,423
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
$
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 09:56 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