Score:0

Need to decompress files and pass the result to a bash script

in flag

I need to use a program that is unable to read compressed files. So I write a script to decompress and then pass the decompressed file to the program.

My script:

#! usr/bin/env bash

dir_in="dir1/$1/$2/$3"
dir_out="Rmes/$1/$2"
mkdir -p ${dir_out}

for file in $(ls -1 ${dir_in})
do
  f=$(gzip -k -c ${dir_in}/${file})
  echo "$f"
  name=${file%.*}
  echo "Calculating the compomd poisson and gaussian data from ${name} file"
  rmes --compoundpoisson -l $4 --max --dna -s ${f} -o "${dir_out}/${name}_k$4_comp_pois"
  #rems --gauss -l $4 --max --dna -s ${dir_out}/${f} -o "${dir_out}/_k$4_gauss"
done

It seems that the script is not working:

PARSE ERROR: Argument: Rmes/$1/$2/outpfilename
             Couldn't find match for argument

gzip: dir1/dir2/dir3/dir4/filename.gz already has .gz suffix -- unchanged

Any of the friends has any suggestion? I really appreciate any tip or script modification.

Paulo

hr flag
You should run your script through [www.shellcheck.net](https://www.shellcheck.net/) and fix the bad practices (like unquoted variable expansions / looping over ls output). But probably the main error is that your gzip command is missing the `-d` / `--decompress` option.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.