#!/bin/sh # # Show line authors of a file # P4 environment variables should be set up already if [ $# -eq 0 ] then echo "Usage: p4blame.sh [file]" exit 1 fi tmpfile=/tmp/content.txt p4 annotate -cq $1 > $tmpfile changes=$(cat $tmpfile | awk '{print substr($1, 0, length($1)-1); }' | sort -u) for change in $changes do author=$(p4 -ztag describe $change | grep user | awk '{print $3}') sed -i "s/$change/$author/g" $tmpfile done cat $tmpfile