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
how to delete content in a file (delete content only) kittusri9 Shell Programming and Scripting 5 05-15-2008 10:12 AM
extract content from a file and insert to another file fredao Shell Programming and Scripting 15 12-06-2006 04:36 PM
Using the content of a file in the name of another anriot Shell Programming and Scripting 2 09-18-2006 04:56 PM
transfer of specific file content to another file mem101 Shell Programming and Scripting 1 10-18-2005 11:01 AM
I need to delete the content out of a number of logs Jbolin01 Shell Programming and Scripting 4 09-30-2003 06:28 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-10-2001
Registered User
 

Join Date: Aug 2001
Location: bangalore india
Posts: 3
Question To delete content of many file

Hi All,

I want to delete the content of some files,which are specified through wild-card option,but i want to restore the file.
I.e I just want to delete the contents file parameters shouldn't be changed.
[Touch is not my answer].

Please provide me the answer.

Thaning u all in advance
Athresh
Forum Sponsor
  #2  
Old 12-10-2001
thangorn
Guest
 

Posts: n/a
echo "" >> filename

will empty the contents of the file
  #3  
Old 12-10-2001
rwb1959's Avatar
Registered User
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
You can also just do...

> filename

...which truncates an existing file or creates a new
"empty" file
  #4  
Old 12-10-2001
Registered User
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
This won't work so well for multiple truncations....

$ > 11*
bash: 11*: ambiguous redirect

Is provided when using any of the methods mentioned above. I think the redirection needs specific filename as it can be used to change create new files too.....

May not be as easy as above..... definitely would be a way with a for loop - however surely there is an easier way????? And I'm not even gonna try the for loop for you as I'm more likely to win a grammy than get it working...
__________________
Pete
  #5  
Old 12-10-2001
rwb1959's Avatar
Registered User
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
for fname in *.?xt
do
> $fname
done
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:40 PM.


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

Content Relevant URLs by vBSEO 3.2.0