5 Usage: ${0##*/} STRACE_LOG
7 Finds all STRACE_LOG.PID files, adds PID prefix to every line,
8 then combines and sorts them, and prints result to standard output.
10 It is assumed that STRACE_LOGs were produced by strace with -tt[t]
11 option which prints timestamps (otherwise sorting won't do any good).
19 for file in "$logfile".*; do
20 [ -f "$file" ] || continue
21 suffix=${file:1+$pfxlen}
22 [ "$suffix" -gt 0 ] 2> /dev/null || {
23 echo "Skipped file '$file' (bad suffix)" >&2
26 pid=$(printf "%-5s" $suffix)
27 # Some strace logs have last line which is not '\n' terminated,
28 # so add extra newline to every file.
29 # grep -v '^$' removes empty lines which may result.
30 sed "s/^/$pid /" < "$file"
33 | grep -v '^$' | sort -k2