In Linux, you have strace:
strace -f sh -c 'grep word1 file > file.txt' Here we use -f to tell strace to trace child process.
In *BSD, you have dtruss (which use dtrace underlying):
dtruss -f sh -c 'grep word1 file > file.txt' OSX has trace. Historical Unix systems have truss (Solaris, AIX, etc.).