I have two scripts, one that is used on a folder with csv files and another on a folder with .tar.gz files. In the second script, I first unzip the files before doing anything with them. Now I want to combine both scripts into one script where a user can specify which folder he/she wants to work with. When the script is run, the user has two options, to either use folderA or folderB. Sort of like a menu.
ScriptA
#!/bin/bash
FOLDER=/path/to/folder
DATE_LOG=`date "+%Y-%m-%d-%H:%M:%S"`
LOG_FILE=/home/kamil/Desktop/Script/log_$DATE_LOG.txt
# Getting the pattern and headers of files from FOLDER
cd "$FOLDER"
for file in *.csv; do
echo -n "${file}" "|" | sed -r 's/(.*)_[0-9]{8}_[0-9][0-9]-[0-9][0-9].[0-9][0-9].csv/\1/'
head -1 "$file"
done | tee $LOG_FILE
ScriptB
#!/bin/bash
FOLDER_HISTO=/path/to/folder/WithTAR.GZ
DATE_LOG=`date "+%Y-%m-%d-%H:%M:%S"`
LOG_FILE=/home/kamil/Desktop/Script/log_$DATE_LOG.txt
# Getting the pattern and headers of files from FOLDER_HISTO
cd "$FOLDER_HISTO"
for zip_file in *.tar.gz; do
file=`tar -xvf $zip_file`
echo -n "${file}" "|" | sed -r 's/(.*)_[0-9]{8}_[0-9][0-9]-[0-9][0-9].[0-9][0-9].csv/\1/'
head -1 "$file"
done | tee $LOG_FILE
FOLDER_HISTO
, but then uses$FOLDER
. Is that a copying error?$FICHIER_LOG
that wasn't set.