I have a text file which contains headers, trailers and detail records.format:H20161010XXX                        // record length: 880  D<---details----total length 880--->D<---details----total length 880--->T2016101020161010          00004    // record length : 880  i want to parse '00004' and perform some calculations on it.I have read the trailer record but I am not able to parse 00004 from ittrailer=`tac $FILE | grep -m 1 '.'`echo $trailer count=$(trailer:29:5)echo $countoutput:T2016101020161010          00004I am not able to pick out 00004.The start position and the length of the 00004 is fixed and I can hard code it. Also I want to store it in a variable and perform arithmetic operations on them.I am writing a shell script using ksh. Many thanks !     
read last line and convert to numeric
shell;ksh
Once you get $trailer:count=$(echo $trailer | cut -d' ' -f2)echo $count