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
while var not empty ruben.rodrigues Shell Programming and Scripting 1 03-11-2009 10:28 AM
Getting same exit status for empty and non empty file mavesum UNIX for Dummies Questions & Answers 4 12-03-2008 09:59 AM
empty the dir ali560045 Shell Programming and Scripting 4 09-05-2008 02:44 AM
how to find empty folders without using -empty lasse UNIX for Dummies Questions & Answers 7 01-17-2008 02:30 AM
/dev/rmt empty ppass SUN Solaris 1 08-04-2005 11:34 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-19-2009
gsiva gsiva is offline
Registered User
  
 

Join Date: Dec 2008
Location: coimbatore
Posts: 107
Need to empty

Hi,

How can I empty the files of *.txt.... in one command.
  #2 (permalink)  
Old 03-19-2009
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
empty ? you mean remove or size 0?
  #3 (permalink)  
Old 03-19-2009
gsiva gsiva is offline
Registered User
  
 

Join Date: Dec 2008
Location: coimbatore
Posts: 107
not to remove, the size to 0...
  #4 (permalink)  
Old 03-19-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
With some shells you can run a loop like this:
Code:
for f in *.txt; do > "$f";done
With others (Z shell with its mult_ios):

Code:
:>*.txt
  #5 (permalink)  
Old 03-19-2009
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
in one command you cant unless its just one file:
Code:
ant:/home/vbe $ ll file.txt
-rw-rw-rw-   1 vbe        bin           1010 Mar 19 19:50 file.txt
ant:/home/vbe $ >file.txt
ant:/home/vbe $ r ll
ll file.txt
-rw-rw-rw-   1 vbe        bin              0 Mar 19 19:51 file.txt
ant:/home/vbe $
  #6 (permalink)  
Old 03-19-2009
gsiva gsiva is offline
Registered User
  
 

Join Date: Dec 2008
Location: coimbatore
Posts: 107
Thank you for your help, but I am trying to empty a set of txt files under one path, and not for a single one... there stands by doubt....

Thank you in advance.
  #7 (permalink)  
Old 03-19-2009
gsiva gsiva is offline
Registered User
  
 

Join Date: Dec 2008
Location: coimbatore
Posts: 107
Thank you for your update, this script [ for f in *.txt; do > "$f";done ] worked out ...
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:03 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