In this page, I'm sharing the model scripts and the details in which scenario it can be used.
========================================================
Scenario 2:
The input file extension is .dat.gz.rdy.
Modify the file name as .dat.gz
Read the row count of .dat file
Get the size of .dat.gz.rdy and print all the values in a file
Input: File path and extension of file.
Source & Destination: Same path on the server.
#!/bin/bash
for file in /home/filename.txt
do
echo $file #print filename on console
FileName=$(bashname "$file") #get only filename without full path
fn="${FileName%.*}" #remove filename extension
Count=$(gzip -dc $file | sed '1d' | wc -l) #get count of original file which is inside the .gz format
Size=$(ls -l $file | awk '{print $5}') #get only size of the file
Output=$(echo $fn,$Size,$Count)
echo $Output
done
========================================================
0 Comments