Shell script to delete all files from system have size zero, Programming Languages

Assignment Help:

 W.A.S.S to delete all such files from the system that have size zero.

 

Program

 

# W.A.S.S to delete all such files from the system that have size zero.

 

total=`ls -lSr | tr -s " "|cut -d " " -f5,9|wc -l`

total=`expr $total - 1`

for w in `ls -lSr | tr -s " "|cut -d " " -f5,9|tail -n$total|head -n1`

do

size=`ls -lSr | tr -s " "|cut -d " " -f5|tail -n$total|head -n1`

name=`ls -lSr | tr -s " "|cut -d " " -f9|tail -n$total|head -n1`

echo "$size  $name"

if test $size = "0"

then

 rm "$name"

echo "$name is deleted.."

else

 exit

fi

total=`expr $total - 1`

done

 

Output

 

sh zsize.sh

 

0  zero.sh

zero.sh is deleted..

0  mbox

             mbox is deleted..

 


Related Discussions:- Shell script to delete all files from system have size zero

Project 1, CSCI 3380 Project 1 For Mano’s Computer design, we have the fol...

CSCI 3380 Project 1 For Mano’s Computer design, we have the following flowchart for fetch and decode phases: Please write the code to simulate the computer to

Oracle, What is "No_Data_Found" in Oracle?

What is "No_Data_Found" in Oracle?

Create single page to demonstrates an xhtml form, Create a single page that...

Create a single page that demonstrates an XHTML form. The form should include all the fields you feel are necessary for submitting an order of books and must include at least one

Write a perl script to assign letter grades to the students, Tasks: Writ...

Tasks: Write a Perl script assignGrades.pl to assign letter grades to the students. Please use the classList2.txt file. Upon invoking, the script will access the file classL

Explain the applet element, Explain the applet Element ? Applets are em...

Explain the applet Element ? Applets are embedded in web pages by using the and tags. The APPLET element is same to the IMG element. Like IMG APPLET references a source fil

Write a function that will read the atoms for a protein, Write a function r...

Write a function readPDBfile('filename') that will read the atoms for a protein stored in a PDB file, whose name is provided as an input to the function (note that this name should

DOM - Document Object Model, What is DOM? The Document Object Model is a pl...

What is DOM? The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure an

What is multithreaded programming, Question: (i) What is multithreaded...

Question: (i) What is multithreaded programming? Lists the benefits achieved by multithreading your code in a program. (ii) What type of coding should be eliminated when d

Calculating percentage differences-circuit diagram, In the procedure sectio...

In the procedure section, it is important to have a clear circuit diagram with component values and a brief, but accurate description of each step taken. 1. Tables for both the

C-program, about how to create the program in c

about how to create the program in c

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd