I would like to execute some basic mathematical calculations in batch/Cygwin, but the solution, described in StackOverflow question: Calculating the sum of two variables in a batch script is using the set /A
command for that matter.
This does not suit me, because I'd like to have everything in a pipe (UNIX style, hence the Cygwin).
My idea is the following: I have a list of files, containing an entry. I'd like to show, for all mentioned file, the one line behind that entry.
Therefore I was thinking about following approach:
Find the line where the entry is found: fgrep -n <entry>
// this shows the line number together with the entry itself
Only show the line number: fgrep -n <entry> | awk -F ':' '{print $1}'
Add '1' to that number
Take the first amount of entries : head -<new number>
Only take the last line : tail -1
But as I don't know how to add 1 to a number, I am stuck here.
I've already tried using bc
(basic calculator) but my Cygwin installation seems not to cover that.
As I want to have everything within one piped line, the usage of set /A
has not sence.
Does anybody have an idea?
Thanks in advance