KoblentsBlog Photography
Contact About
Published Jul 13, 2016
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...]
 
 
« September 2016 June 2016 »
© Copyright Koblents.com, 2012-2024