1752778 Members
6123 Online
108789 Solutions
New Discussion юеВ

Re: printing in awk

 
Sanjay_6
Honored Contributor

Re: printing in awk

hi,

Try

echo `cat file_name |awk '{y=x "\n" $0; x=$0};END{print y}'|awk '{for (i=1; i<=NF; i++) s=-$1-s}; END{print s}'`

This will subract the last line from the last-1 line. They have to be numeric values.

someone might have a shorter way.

Hope this helps.

Regds
Rodney Hills
Honored Contributor

Re: printing in awk

Here is something pretty straight forward-

awk '/Start/{a=1};{if (a) print $0}' file

(how about assigning points to all that have helped...)

HTH

-- Rod Hills
There be dragons...
Hein van den Heuvel
Honored Contributor

Re: printing in awk

awk '{y=x; x=$1} END {print x-y}' inputfile