I want to subtract first field of row1 and row2 and store a result in a
variable say "diff". Then
I want to subtract first field of row3 and row4 and store a result in the
variable say "diff". Similary...for rows 5 and 6 and soon......
I am using kshell. I know I have to use AWK or sed but dont know how to.
Any help is apreciated.
so I m reading all lines one by one and fetching 1st and 3rd value of a line separated by space. after than just echoing the diff as per your requirement.
script.sh[6]: full - new: 0403-009 The specified number is not valid for this command.
xargs: 0402-057 The /usr/bin/echo command was not found or could not be run.
And could u pls describe ur code.I would appreciate that.
awk 'NR>1 # NR(record number) greater than 1
{s=$1 # assign first column of current record to s
getline # get next line
print "Diff =" s-$1 # print s(previous record) minus $1(current record)
}' infile