Hi All,
I have a sftp session log where I am transferring multi files by issuing "mput abc*.dat". The contents of the logfile is below -
#################################################
Connecting to 10.75.112.194...
Changing to: /home/dasd9x/testing1
sftp> mput abc*.dat
Uploading abc140212095613.dat to /home/dasd9x/testing1/abc140212095613.dat
abc140212095613.dat 100% 21 0.0KB/s 00:00
Uploading abc140212095639.dat to /home/dasd9x/testing1/abc140212095639.dat
abc140212095639.dat 100% 25 0.0KB/s 00:00
Uploading abc140212095648.dat to /home/dasd9x/testing1/abc140212095648.dat
abc140212095648.dat 100% 43 0.0KB/s 00:00
Uploading abc140212095658.dat to /home/dasd9x/testing1/abc140212095658.dat
abc140212095658.dat 100% 35 0.0KB/s 00:00
Uploading abc140212095710.dat to /home/dasd9x/testing1/abc140212095710.dat
abc140212095710.dat 100% 27 0.0KB/s 00:00
Uploading abc140212095719.dat to /home/dasd9x/testing1/abc140212095719.dat
abc140212095719.dat 100% 40 0.0KB/s 00:00
Uploading abc14022012.dat to /home/dasd9x/testing1/abc14022012.dat
abc14022012.dat 100% 52 0.0KB/s 00:00
sftp> ls -l
drwxr-xr-x 0 600598020 600598020 1024 Feb 16 14:35 .
drwx------ 0 600598020 600598020 1024 Feb 16 14:34 ..
-rw-r--r-- 0 600598020 600598020 0 Feb 16 14:32 a.dat
-rw-r--r-- 0 600598020 600598020 21 Feb 16 14:35 abc140212095613.dat
-rw-r--r-- 0 600598020 600598020 25 Feb 16 14:35 abc140212095639.dat
-rw-r--r-- 0 600598020 600598020 43 Feb 16 14:35 abc140212095648.dat
-rw-r--r-- 0 600598020 600598020 35 Feb 16 14:35 abc140212095658.dat
-rw-r--r-- 0 600598020 600598020 27 Feb 16 14:35 abc140212095710.dat
-rw-r--r-- 0 600598020 600598020 40 Feb 16 14:35 abc140212095719.dat
-rw-r--r-- 0 600598020 600598020 52 Feb 16 14:35 abc14022012.dat
-rw-r--r-- 0 600598020 600598020 0 Feb 16 14:32 b.dat
-rw-r--r-- 0 600598020 600598020 0 Feb 16 14:32 c.dat
-rw-r--r-- 0 600598020 600598020 0 Feb 16 14:32 d.dat
sftp> quit
#################################################
This log has been captured in a file called sftp_log. Now I am out of the sftp session and I have this sftp_log for my referance. I want to check the log and find out if all the files (resembling abc*.dat) are transferred as per size. So, I want to find the lines where the abc*.dat files were long listed. I have the abc*.dat captured in a variable named TRANSFERRING_FNAME. So I used this variable to be passed in awk and search the desired lines by below command -
awk -v fname="$TRANSFERRING_FNAME" 'substr($1,1,1) == "-" && $9 ~ fname {print $9 "|" $5}' sftp_log
But it is not returning anything. Actually I needed only below lines from the sftp_log -
###################################################
-rw-r--r-- 0 600598020 600598020 21 Feb 16 14:35 abc140212095613.dat
-rw-r--r-- 0 600598020 600598020 25 Feb 16 14:35 abc140212095639.dat
-rw-r--r-- 0 600598020 600598020 43 Feb 16 14:35 abc140212095648.dat
-rw-r--r-- 0 600598020 600598020 35 Feb 16 14:35 abc140212095658.dat
-rw-r--r-- 0 600598020 600598020 27 Feb 16 14:35 abc140212095710.dat
-rw-r--r-- 0 600598020 600598020 40 Feb 16 14:35 abc140212095719.dat
-rw-r--r-- 0 600598020 600598020 52 Feb 16 14:35 abc14022012.dat
###################################################
From these lines I want to extract the file name and their corresponding size like below -
############################################
abc140212095613.dat|21
abc140212095639.dat|25
abc140212095648.dat|43
abc140212095658.dat|35
abc140212095710.dat|27
abc140212095719.dat|40
abc14022012.dat|52
############################################
And the value in $TRANSFERRING_FNAME can vary so we can't manupulate on hard coded value like 'abc'. Could anyone please advise.
Thanks & Regards,
Bijitesh