Extracting performance statistics from FTP session transcript I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd love to see what can be done. Be a learning lesson for me.

Excerpt of input:

ftp&gt; !:--- FTP commands below here ---
ftp&gt; lcd C:\Utilities\Performance_Testing\
\Utilities\Performance_Testing\: File not found 
Verbose mode On .
ftp&gt; verbose
binary
200 Switching to Binary mode.
ftp&gt; put "test_file_5M.bin"
200 PORT command successful.
150 Ok to send data.
226 File receive OK.
ftp: 5242880 bytes sent in Seconds Kbytes/sec.
ftp&gt; 44.81117.00disconnect
221 Goodbye.
ftp&gt; bye 


Code:

#Obtain UT external put value.
ut1intput=$(awk '
  NR==70 {
    for(i=1;i&lt;=NF;i++) { 
      if($i=="ftp&gt;") {
        sub(/disconnect/, "", $(i+1));
        print $(i+1)
      }
    }
  }' filename.txt)

utintputvalue=`echo $ut1intput | awk -F. '{print $2"."$3}'| sed  's/^..//'`


Output:

utintputvalue is 117.00
Assuming the "Output" section is stored in "filename.txt", and assuming you have GNU tools:

grep -oP '(?&lt;=\.\d\d)\d+\.\d\d(?=disconnect)' filename.txt


That's a perl regex meaning: prececeded dot and two digits, find some digits, a dot and two digits, followed by "disconnect". grep's -o option means "output only the matched text".