Explore BrainMass

Explore BrainMass

    Unix/Linux Shell Script to Count Number of Modified Files

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    File "Ageing" Shell Script

    A) Write a shell script that will count the number of files in your account that were last modified 5 or more days ago. When you run the shell script, the results should look something like this:

    % ageing
    there are 19 filles modified 5 or more days ago.
    %

    B) Modify your script (or re-write it if you wish) to allows the user to choose what the script should use for the last modified day. Example:

    % ageing 15
    There are 4 modified files 15 or more days ago.

    C) Modify the script to get it to back up to "X" number of days and list the files that were modified for each day. Example:

    % ageing -3
    Files modified 1 day ago
    ./a.txt
    ./b.txt

    Files modified 2 days ago
    ./2days.txt
    ./dir1/test_file.txt
    ./dir2/test_file2.txt

    Files modified 3 days ago
    (none)

    © BrainMass Inc. brainmass.com March 4, 2021, 5:48 pm ad1c9bdddf
    https://brainmass.com/computer-science/files/12040

    Attachments

    Solution Preview

    Assuming by modification you mean modification of file data ( that is what a file is mostly modified for; i.e change of its data ) then

    A)
    This problem is very simple and straightforward. You just have to lookup
    man find
    to find out about the mtime flag ...

    Solution Summary

    This solution will teach you how to write various Bash Shell scripts to check the number of files that have been modified X number of days ago.

    $2.49

    ADVERTISEMENT