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
Deleting from Mac on GUI? wmosley2 OS X (Apple) 1 12-10-2003 08:06 PM
Deleting by ID boyler Shell Programming and Scripting 1 09-23-2003 07:37 PM
Printing Problems in unix ... ( Bar-cdoe - Ip Printing) QuickSilver UNIX for Advanced & Expert Users 3 06-04-2002 07:48 AM
deleting lines supercbw High Level Programming 1 05-06-2002 09:53 AM
usb - deleting (irq) termiEEE UNIX for Dummies Questions & Answers 1 04-18-2002 02:56 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-10-2008
Registered User
 

Join Date: Oct 2008
Posts: 7
Post printing and deleting using awk

I am trying to print and delete at the same time 0KB files... using following command

a-> find . -type f | xargs ls -l | awk '{ if($5 == 0) {print $0;}}' | xargs rm $0

but am not successful. Can somebody tell me how to do this ... same time I need files to be printed as well deleted later.

I used tee command as well like this

b-> ListFilesZKB | tee | xargs rm $0

where ListFilesZKB is shell script for (a) excluding last pipe.


Reply With Quote
Forum Sponsor
  #2  
Old 10-10-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 958
Tadaaaa:
Code:
find . -type f -size 0 -print -exec rm {} \;
Reply With Quote
  #3  
Old 10-10-2008
Registered User
 

Join Date: Oct 2008
Posts: 7
Hi I tried the same u specified it didnt work all zero KB files still present.
But this wont give any error message, just gets completed.
Reply With Quote
  #4  
Old 10-10-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,275
Something is not right, zaxxon's example is correct, based on what you asked.

What output does this produce?
Code:
find . -size 0 -exec ls - l {} \;
Does it find zero-length files or not? If not try changing -size 0 to -size -1
Reply With Quote
  #5  
Old 10-10-2008
Registered User
 

Join Date: Oct 2008
Posts: 7
thx it worked ... but I wanted listing of files in long format.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




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