function get_depth(line) { sub(/[^ ].*/, "", line); return length(line); } BEGIN { path = "/"; proj = PROJECT; } (NR == 1) { next; } (! /\/$/) { next; } (1) { depth = get_depth($0); thisdir = substr($0, depth+1); sub(/\/$/, "", thisdir); d = split(path, dirs, "/"); path = ""; for (i = 2; i < depth+1; ++i) { path = path "/" dirs[i]; } path = path "/" thisdir; if (thisdir == "trunk") { trunkpath = substr(path, 2) if (depth == 1) { print proj " " proj " " trunkpath } else { print proj " " dirs[depth] " " trunkpath } } next; }