1

My script skills are really limited so I wonder if someone here could help me. I would like to download 2 files, run gunzip, run a command called tv_merge and then gzip the new file. Here's what I Would like to be run from a script.

I would like to download two files (.gz) with wget:

wget -O /some/where/file1.gz http://some.url.com/data/
wget -O /some/where/file2.gz http://some.url.com/data/

Then gunzip the 2 files:

gunzip /some/where/file1.gz
gunzip /some/where/file2.gz

After that run a command called Tv_merge:

tv_merge -i /some/where/file1 -m /some/where/file2 -o newmaster.xml 

After tv_merge. I would like to gzip the file:

gzip newmaster.xml

I would like to run all these commands in that order from a script, and I would like to put that to be run let's see every 8h like a crontab.

Chem-man17
  • 1,700
  • 1
  • 12
  • 27
LewHam
  • 11
  • 1

1 Answers1

1

I'm assuming that file names are static. with provided information this should get you going.

#!/bin/bash
echo "Downloading first file"
wget -O /some/where/file1.gz http://some.url.com/data/
echo "First Download Completed"
echo "Downloading Second file"
wget -O /some/where/file2.gz http://some.url.com/data/
echo "Second Download Completed"
gunzip /some/where/file1.gz
gunzip /some/where/file2.gz
echo "Running tv_merge"
tv_merge -i /some/where/file1 -m /some/where/file2 -o newmaster.xml
gzip -c newmaster.xml > /some/where/newmaster.xml.gz
echo "newmaster.xml.gz is ready at /some/where/newmaster.xml.gz"

Save this to a file for example script.sh then chmod +x script.sh and you can run it with bash script.sh.

Farhad Farahi
  • 35,528
  • 7
  • 73
  • 70