#!/bin/sh # example: dtnsim -n 10 -M Log | ./p-coverage.sh 10 50 # Extract N and p from command-line arguments. n=$1; shift p=$1; shift # Calcurate the stop criteria. threshold=$(($n * $p / 100 - 1)) # Exclude non-forwarding line from STDIN. grep forward | # Discard duplicate message transmissions. grep -v dup | # Display the THRESHOLD-th line sed -n "${threshold}p" | # Display only the first field. awk '{ print $1 }'