grepall - a shell script using grep
#!/bin/bash
grep -i "$*" *[^~] | less
Send private message to frappyjohn
At our February meeting, Barton indicated it is better to...
At our February meeting, Barton indicated it is better to use "$@" instead of "$*":
grep -i "$@" *[^~] | less
Send private message to frappyjohn
Even better, with color!
Even better, with color!
- Adding --color=always to grep tells it not to suppress color when piping
- Adding -R to less tells it to display the actual color, not the escape sequence passed thru the pipe
- Adding -C 3 to grep causes it to show three lines of context before and after each occurrence found
#!/bin/bash
grep --color=always -C 3 "$@" *[^~] | less -R
Send private message to frappyjohn