0

Tip #770   Append a sequential number to a file

The command below will append a number to a file to count events, minutes, actions etc.

awk '{x=NR+1}END{print x}' /path/to/file >> path/to/file

Example usage:

> cat example
1
> awk '{x=NR+1}END{print x}' example >> example
> awk '{x=NR+1}END{print x}' example >> example
> awk '{x=NR+1}END{print x}' example >> example
> cat example
1
2
3
4