Extract file names from a 7-zip archive one-by-one and use the name as a parameter to a java program in a terminal
2
votes
2
answers
1462
views
I am trying to write a bash script that will first extract files one-by-one from an archive and call a java program with the file name as a parameter to do something. I have tried with the following script, but it does not work.
I am facing the following problem:
Assuming the compressed file name is
compressed.7z
. Say there are two files inside the compressed.7z archive: sample_1.json
and sample_2.json
(could be anything). The 7za
command always outputs compressed.7z
as file name, which I don't want. I just want to get the extracted sample_1.json
in the output folder, and give the name to the java command, then sample_2.json
in the next iteration.
Could anybody can help in this issues?
Thanks in advance.
lang-sh
#!/bin/bash
for file in *.7z
do
7za x -ooutput "${file}" | java -jar Remove_BoilerPlate_JSON_Updated.jar "${file}";
done
Asked by Md Asaduzzaman
(21 rep)
Sep 14, 2021, 11:26 PM
Last activity: Sep 19, 2021, 07:08 PM
Last activity: Sep 19, 2021, 07:08 PM