Skip to content

Instantly share code, notes, and snippets.

@chrismyang
Created August 29, 2017 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismyang/f52055eda85f6170ec8a44cdb619d41c to your computer and use it in GitHub Desktop.
Save chrismyang/f52055eda85f6170ec8a44cdb619d41c to your computer and use it in GitHub Desktop.
Log Consolidation

Log Consolidation

We have log files spread out over several directories and want to automate the process of consolidating them back to a single location. Your task is to create a script that will perform this consolidation. Note that this script must be designed to run on different systems, which means that your script must be able to run on a system that is different than the one you have access to for this test.

Instructions

Create a script in the file consolidate_logs.sh that does the following:

  • For each log file in the LOG_LOCATIONS environment variable, copy that file to the location specified in LOG_DESTINATION but do not overwrite any files that already exist in LOG_DESTINATION

  • If a file in the LOG_LOCATIONS environment variable is already present in LOG_DESTINATION append its name to LOG_DESTINATION/duplicate_files.txt

  • If a file in the LOG_LOCATIONS environment variable is missing, append its name to LOG_DESTINATION/missing_files.txt

  • Items in the LOG_LOCATIONS list should be processed in the order they appear in the list.

  • The LOG_LOCATIONS environment variable defines a comma separated list of absolute paths to log files.

  • The LOG_DESTINATION environment variable specifies a directory into which we are consolidating log files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment