Skip to content

vittoriodedi/operatingsystems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

operatingsystems

This repository contains my final project for the “Sistemi Operativi” course. The project consists of a Bash script that implements a custom command called aggiorna, which can be used to synchronize files from one folder to another based on specific conditions.

Description

The aggiorna command takes two parameters, both of which must be pathnames (either absolute or relative) of directories. The script performs a series of checks and, if all are satisfied, it selectively copies files from the first directory to the second.

Requirements and Behavior

  • The two directories:

    • Must not be symbolic links.
    • Must not contain each other (i.e., one cannot be a subdirectory of the other).
    • Must be at the same depth in the filesystem hierarchy.
  • Once the initial checks pass, the script:

    • Iterates over all regular files in the first directory.

    • For each file:

      • If the file does not exist in the second directory, it is copied.

      • If the file does exist, the script compares modification times:

        • If the file in the first directory is more recent, it is copied and overwrites the existing file in the second directory.
        • Otherwise, the file is not copied.

Note: The copy operation is one-way only, from the first directory to the second. No changes are made in the opposite direction.

Usage

./aggiorna.sh <source_directory> <target_directory>

Example:

./aggiorna.sh ./dir1 ./dir2

Error Handling

If any of the input requirements are not met (e.g., symbolic links are provided, directories are nested, or at different levels), the script will display a clear error message and terminate without making any changes.

About

This repository contains my “Sistemi Operativi” course final project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages