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.
#!/bin/bash
for file in *.7z
do
7za x -ooutput "${file}" | java -jar Remove_BoilerPlate_JSON_Updated.jar "${file}";
done
7za l
on second run? – alecxs Sep 18 '21 at 13:07