Hacker News new | past | comments | ask | show | jobs | submit login

Probably slower than the go version, but more flexible since you have more over the files processed.

        # bash
	# find/replace
	function fr {
		local pattern=$1
		local replacement=$2
		local program

		if [[ -z "$replacement" ]]
		then
			program="grep $pattern"
		else
			program="sed -i s/$pattern/$replacement/g"
		fi

		while read line
		do
			$program "$line"
		done
	}

	# usage
	find . | fr find-this
	find . | fr replace-this with-that



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: