Write a program to find files-unix, C/C++ Programming

This programming assignment is for use in the LINUX/UNIX environment!!

Introduction:

System administration often requires custom written programs and tools. One problem a system admin faces is deleting oversized files on the system.

Assignment Description:

This assignment is to write a program to find files that exceed a given threshold in size.  This tool will allow the system admin to find those files that are dominating the usage of the file system.

Program Requirements:

1)  The program will take 2 arguments, an options argument and a size argument.

2)  The size argument is a number representing the threshold size.  For example, if 10 is entered, it will find all files larger than 10 megabytes.

3)  The options are to be as follows:

      1.  -f  (this option will display the file name

      2.  -s (this option will calculate the summary of all file sizes)

      3.  -t  (this option will display the total summary only.

    These arguments may be entered in single option fashion or multiple.  Example:

  $filesize -sf 10

  -This will display all files over 10 megabytes and include a summary of all files sizes.

   The output is as follows:

    80 /home/smith/Tools/decode.tgz

    28 /home/smith/Tools/parse_code.a

   **NOTE: that decode.tgz is 80 MB and parse_code.a is 28 MB.

4)  The program will take the file list in as a stream from the standard input.  The "find" command will be used to create the stream, but no options will be allowed to be used.

    The "find" command is used here as a simplifying element of the program.

5)  The program will use the "stat" system call to filter out dir/block/link/socket files and only return "regular" files.

6)  The program will use the "stat" system call to get the file size.

 

SAMPLE CODE THAT CAN BE USED (You Don't HAVE to use this):

For POSIX environment:

struct stat sb;

int result = 1; /* result */

if (msg) msg[0] = '\0';

if (stat(FN,&sb) == 0) {

     if      (S_ISDIR (sb)) result = 0;

     else if (S_ISFIFO(sb)) result = 0;

     else if (S_ISBLK (sb)) result = 0;

     else if (S_ISSOCK(sb)) result = 0;

   }

}

Posted Date: 3/26/2013 2:41:28 AM | Location : United States







Related Discussions:- Write a program to find files-unix, Assignment Help, Ask Question on Write a program to find files-unix, Get Answer, Expert's Help, Write a program to find files-unix Discussions

Write discussion on Write a program to find files-unix
Your posts are moderated
Related Questions
Write a program to define a matrix: 1. Write a function that takes an integer and calculates and returns the factorial of the integer. The Factorial of a number "n" is compute

Convert a COV/CPE (Micosoft Fax Cover Page) file to a TIF image file Project Description: I would like a small API written that will take a COV/CPE file and replaced the corr

Need to Fix a code written in c++,SDL2.00 for high CPU and memory leak There is a 2D simple game written with SDL2.00 using c++. The game isn't complete and the code is a little

Define a structure in C++: Write a program a structure in c++ program. void main() {                 struct player                 {                 char name[2

Define the Keywords of c language? C keeps a small set of keywords for its personal use. These keywords can't be used as identifiers in the program. Here is the list of keyword

define a class for student

(a) Write a procedure called (mult x y) that multiplies two numbers x and y in a recursive manner using successive addition. Specifically, note that a x b = a + a + .... + a (b tim

#questionHi, I am looking for help with the assignment, can you help..

Program: Write a program that predicts users' age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an

Develop a C++ program that uses a while to determine the gross pay (in Dollars) for each of several employees. The company pays “straight-time” for the first 40 hours worked by ea