​
Bash Script - Decompress
Bash script to decompress a file based on its extension and the ability to move the extracted data to a new directory and remove the original file.
​
Purpose: To practice bash scripting and improve my own knowledge.
Features
Correct type of uncompressing command to use
Ability to decompress into new folder or initial folder
Ability to keep file or delete after decompressing
Three Functions
-
Extract based on file type
-
Delete original file by choice
-
Move extracted files to a new directory
Test Case
Extract
Remove
Move
Run
Lessons Learned:
1. #!/bin/bash must be the first line in the script as it determines how it is interpreted by the kernel
2. functions are a great way to organize the script
3. function outputs only strings or return codes, had to work around moving the file extracted
​
Sources
https://www.networkworld.com/article/3244007/extracting-from-compressed-files-on-linux.html