printing and deleting using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printing and deleting using awk
# 1  
Old 10-10-2008
Java 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  
Old 10-10-2008
Tadaaaa:
Code:
find . -type f -size 0 -print -exec rm {} \;

Smilie
# 3  
Old 10-10-2008
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  
Old 10-10-2008
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  
Old 10-10-2008
thx it worked ... but I wanted listing of files in long format.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use awk for deleting columns?

Hi folks, How awk 'll help to do this file contains bunch of insert statement like below remove fourth column from all statement put it in new file INSERT INTO `tbl_medicalquestions` VALUES (1,'Is anyone waiting for an operation, post operative check up, any other hospital treatment or... (12 Replies)
Discussion started by: ashutoshverma
12 Replies

2. Shell Programming and Scripting

Deleting column using awk

How Can we delete a range of coloumns using awk? (or any other method is fine) If we have a file which has about 200 coloumns. I need to delete a particular range lets say for eg from $6 to $119 Can we do this using cut, if yes the cut command would also be helpful. many thanks in... (4 Replies)
Discussion started by: Sri3001
4 Replies

3. Solaris

Deleting printing everywhere

I am in a prison system with a standalone (no internet connection) Solaris 8 network using Sun-Rays for clients (so no software is on the client side). We are finding a problem where inmates are using the print-to-file function to be able to rename folders everywhere on the server, meaning they are... (1 Reply)
Discussion started by: ixeye
1 Replies

4. Shell Programming and Scripting

Awk printing help

Hallo, i have a file which looks like this: $1 $2 $3 Student1 55 Pass 55 Pass 35 Fail Student2 55 Pass 55 Pass 35 Fail i want that the $1 field... (3 Replies)
Discussion started by: saint2006
3 Replies

5. Shell Programming and Scripting

Deleting keys and values-Awk

key pair is 1st and 6th column ex:a20 : p10 or a20 : p11 For every key pair if the vlaue(4th column) is the same then delete all the lines who has keypair and the value ex: a20 : p10 has value 1 only then delete those but a20 : p11 has different values 1,2 and 3 and keep those. input a20 ... (8 Replies)
Discussion started by: ruby_sgp
8 Replies

6. Shell Programming and Scripting

Deleting files in awk

Hi All, I have about 10000 files having names of the same pattern I am using awk to match the pattern. Inside the awk block how can i delete all the 10000 files.. Or is there any other way to delete files in bulk... "rm" command fails with the message that argument list is... (9 Replies)
Discussion started by: abhinav192
9 Replies

7. Shell Programming and Scripting

Deleting every 3rd field using awk

I have a file whose format is like the following 350,2,16.2,195,2,8.0 every 3rd column of this file should be deleted. How can i achieve this tried with the following iostat -D -l 2 | /usr/xpg4/bin/awk ' NR>2 { for (i=0;i<=NF;i++)if(i%3==0)$i=""};' but no luck (3 Replies)
Discussion started by: achak01
3 Replies

8. Shell Programming and Scripting

AWK Printing

i have a file and i want to print the second variable and add qoutes to it i do awk -F"|" '{print $2}' star.unl. i get the output xxxxxxx but i need the variable($2) to be in quotes.like "xxxxxxx" how do i do there please (3 Replies)
Discussion started by: tomjones
3 Replies

9. Shell Programming and Scripting

deleting lines using awk-best way?

Hi all....I'm using awk to validate a csv file, but now I've been told to delete any invalid lines from the file.. Im not sure what the best way to do this is? Would it be to create a temp file say "csv_temp.tmp" file and print all the valid records to that temp file. Then delete the old file... (3 Replies)
Discussion started by: satnamx
3 Replies

10. Shell Programming and Scripting

AWK printing

Hello, I am trying to write a formatted report into a file using .ksh script and awk. Here is the command I am trying to run echo "before awk" ${SRC_SCHEMA} echo | awk '{printf "%-20s", ${SRC_SCHEMA} }' >>$REPORT_SQL_NAME I get the following error before awk ADW awk: 0602-562 Field $()... (1 Reply)
Discussion started by: fastgoon
1 Replies
Login or Register to Ask a Question