While the function works, it will not be available for other programs and scripts (without much pain). (The alias would have the same problem.) I would choose a separate script, because it sounds like you want to call it directly:
#!/bin/bash # since you're already using bash, depend on it instead of /bin/sh # and reduce surprises later (you can always come back and look at # porting this) INCLUDE="*.$1" PATTERN="$2" grep --color -n "$PATTERN" --recursive --include="$INCLUDE" .
(There is no need to find what you have.)
If it were used only in another script instead of direct, the function would be simpler.
Roger Pate
source share