'Unzip a specific file to specific folder bash script
I am trying to unzip a zip file that has a .csv file in it inside a another folder. I want to extract just this .csv file to a specific folder. The problem I am facing is the .csv ends up inside another folder.
Here is my bash file
#!/bin/bash
inotifywait -m ./zips -e create -e moved_to |
while read dir action file; do
echo "The file '$file' and name '${file%.*}' appeared in directory '$dir' via '$action'"
# do something with the file
unzip -o -q "zips/$file" "${file%.*}/*_jld.csv" -d /home/ubuntu/test_files/csv
#..............................
done
My Zip file content:
.
├── zips_making
├── useless_jld.csv
├── useless_json.json
└── useless_txt.txt
Current Directory:
── csv
│ └── zips_making
│ └── useless_jld.csv
└── zips
└── zips_making.zip
I want the directory to look like this:
── csv
│ └── useless_jld.csv
│
└── zips
└── zips_making.zip
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
