Hi,
I want to process all input files available into folder (C:\ShellPrg\InputFile\) Input files are abc.CSV , XYZ.zip (zip of CSV file), PQR.gz (zip of CSV file).
I want to check the extension of file, If its .zip/.gz then need to unzip the file as .CSV
I want to parse line by line of each .CSV file.
Here is my code,
FILE=$1
echo $FILE
EXTN=`echo $FILE | cut -d "." -f 2`
if [ $EXTN == "zip" ]; then
input_file=`unzip $FILE`
echo "input file is $input_file"
elif [ $EXTN == "gz" ]; then
input_file=`gzip -d $FILE`
fi
EXTN1=`echo $input_file | cut -d "." -f 2`
if [ $EXTN1 == "CSV" ]; then
// code of line parse
fi
where $1 = <PATH> a_b_c_d_1234.CSV / a_b_c_d_1234.zip / a_b_c_d_1234.gz
How can I put the for loop to process each file from folder?
Also help me to unzip the file and store the unzipped file name into a variable?