#!/bin/bash data_file=./data.txt exec 200>./bla-lock flock -x 200 || exit 1 nr=$(cat $data_file) ((nr=nr+1)) echo $nr >$data_file