look-at-log.bash 896 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. set -Eeuxo pipefail
  3. # current script directory
  4. DIR="$(cd "$(dirname "$0")" > /dev/null 2>&1; pwd -P)"
  5. printf "script directory: %s\n" "${DIR}"
  6. if [ -z ${1+x} ]; then
  7. printf "%s\n" "No log file specified.";
  8. exit 1;
  9. else
  10. printf "%s %s %s\n" '${1}' 'is set to' "${1}";
  11. COMPRESSED_LOG_FILE="${1}"
  12. fi
  13. COMPRESSED_FILE_NAME="$(basename -- ${COMPRESSED_LOG_FILE})"
  14. # DECOMPRESSED_FILE_NAME=$(echo "${COMPRESSED_FILE_NAME}" | rev | cut --fields '2-' --delimiter '.' | rev)
  15. DECOMPRESSED_FILE_NAME="${COMPRESSED_FILE_NAME%.*}"
  16. cp --verbose "${COMPRESSED_LOG_FILE}" "${DIR}/${COMPRESSED_FILE_NAME}"
  17. # z8qdlxa1c3bjdcx91p200vgxdkwfyg-python-jupyterlab-server-2.0.0rc1.drv.bz2 ->
  18. # z8qdlxa1c3bjdcx91p200vgxdkwfyg-python-jupyterlab-server-2.0.0rc1.drv
  19. bzip2 --decompress "${COMPRESSED_FILE_NAME}"
  20. cat "${DECOMPRESSED_FILE_NAME}"
  21. rm --verbose "${DECOMPRESSED_FILE_NAME}"