I don't think sed can do this, but perl can and is only slightly more complex:
echo "a b c syscall=257 success=yes" | perl -pe 's:syscall=(\d+):"SYSCALL=" . `ausyscall $1`:e' Although, that will most likely add an extra newline there which you don't want. So you might need this instead:
echo "a b c syscall=257 success=yes" | perl -pe 's:syscall=(\d+):chomp($v=`ausyscall $1`); "SYSCALL=$v" :e' Perl's s operator works pretty much the same way as sed's. The only difference here is that by using the e flag at the end (s:old:new:e), that allows us to run perl code in the replacement side, and use the result of the code. The code in question is:
`ausyscall $1`: runsshwithausyscall what-is-captured-by-the-first-pair-or-parensas code to interpret which here, since that's only digits will runausyscallpassing it those digits as an argument ($1is the equivalent to sed's\1) and that command's output is collected (similar to the`...`shell operator except that trailing newline characters are not stripped and it doesn't choke on NUL bytes like most shells do).`ausyscall $1`: runausyscallpassing it$1(this is the equivalent to sed's \1—although Perl can also work with \1, just not with theeflag—so it's whatever was captured by the first set of parentheses) as an argument. Note that the command is run in the default shell of the system (usuallysh).chomp($v=`...`): remove trailing newlines. This removes the newline returned by theausyscallcommand. The result is stored in the variable$v.chomp($v=`...`): remove trailing newlines. This removes the newline returned by theausyscallcommand. The result is stored in the variable$v."SYSCALL=$v": this returns the desired output."SYSCALL=$v": this returns the desired output.
Note that this is a risky approach. It is fine here, in this specific case, since you are explicitly only capturing numerical digits, but as a general rule, you don't want to execute arbitrary input as a command as that makes you vulnerable to a code injection attack.