Ad Code

Find File

 In this page, I'm sharing the model scripts and the details in which scenario it can be used.


It's not limited to given scenario, we can manipulate the scripts based on the requirements.

Make sure you are testing these scripts in your test environment, before using it on production.

======================================================== 

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

======================================================== 

Reactions

Post a Comment

0 Comments