Tuesday, September 25, 2012

Search string in multiple files in linux

Search string in multiple files in linux, use following function in .bashrc file of linux.

srcfind() {
if [ $# -gt 0 ]; then {
find . -type f -name "$1" -print0 |xargs -0 -r grep -n --color "$2" "$3" "$4" "$5" 2>/dev/null;
} else {
echo "Usage: srcfind filetype string_to_find option_for_grep";
} fi;
}


No comments:

Post a Comment