top of page

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

  1. Extract based on file type

  2. Delete original file by choice

  3. Move extracted files to a new directory

Test Case

Screenshot 2020-12-21 213247.png
Screenshot 2020-12-21 213312.png

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

bottom of page