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 and shell scripting languages 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 11:06 PM
Deleting by ID boyler Shell Programming and Scripting 1 09-23-2003 11:37 PM
Printing Problems in unix ... ( Bar-cdoe - Ip Printing) QuickSilver UNIX for Advanced & Expert Users 3 06-04-2002 11:48 AM
deleting lines supercbw High Level Programming 1 05-06-2002 01:53 PM
usb - deleting (irq) termiEEE UNIX for Dummies Questions & Answers 1 04-18-2002 06:56 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 10-10-2008
vivek.gkp vivek.gkp is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
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.


  #2 (permalink)  
Old 10-10-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,289
Tadaaaa:

Code:
find . -type f -size 0 -print -exec rm {} \;

  #3 (permalink)  
Old 10-10-2008
vivek.gkp vivek.gkp is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
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.
  #4 (permalink)  
Old 10-10-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,789
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
  #5 (permalink)  
Old 10-10-2008
vivek.gkp vivek.gkp is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
thx it worked ... but I wanted listing of files in long format.
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 01:42 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