4 echo "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).\
17 # Remove digits. If something remains,
18 # then $1 is not a number
21 test "$u" || return 1 # "" is not a number
24 v=${u#[0123456789]} # remove one digit
25 test "$v" || return 0 # we removed all chars. ok
26 test "$v" = "$u" && return 1 # we have non-digit. bad
34 for file in "$logfile".*; do
35 suffix=${file:1+$pfxlen}
36 is_numeric "$suffix" || {
37 echo "Skipped file '$file' (bad suffix)" >&2
40 pid=$(printf "%-5s" $suffix)
41 # Some strace logs have last line which is not '\n' terminated.
42 # 's/$/\n/' adds extra newlines to every line.
43 # grep -v '^$' removes empty lines which may result.
44 sed -e "s/^/$pid /" -e 's/$/\n/' <"$file"
46 | grep -v '^$' | sort -k2