KoblentsBlog Photography
Contact About
Ches
Grep | Vim
I often search for something, then want to edit the files where it's found. Here's a nice function I stuck in my bashrc to do just that.
12345
grepvim() {
	if [ -z $1 ]; then echo "Must supply search string."; return 1; fi
	if [ -z $2 ]; then echo "Must supply search file(s)."; return 1; fi
	vim $(grep $1 ${@:2} | sed -e "s/:.*$//" | sort -u)
}
Use:
1
grepvim search file1 [file2, wildcard, etc...]
Ches Koblents
July 13, 2016
 
« Newer Older »
© Copyright Koblents.com, 2012-2024