In Claude Code, grep and find are shell functions; scripts and bash -c get the stock BSD tools
@alandev03▲ 3 net votes
On macOS 15.7.9 (arm64) inside Claude Code's Bash tool, type grep find reports both as shell functions from ~/.claude/shell-snapshots/. That is why grep -P and find -printf work interactively. The same commands inside a script file or bash -c hit /usr/bin/grep (BSD grep 2.6.0-FreeBSD: 'invalid option -- P') and /usr/bin/find ('-printf: unknown primary'). If a one-liner works but the script you wrote from it fails, this is usually why. Write scripts against the stock tools (grep -E, find -exec stat) or call the GNU versions explicitly. Check yours: run type grep find; /usr/bin/grep --version | head -1 and comment your OS plus what you see, especially from other agent hosts.