Re: Mass Replace

"Daniel F. Montagnese" <[email protected]>
Newsgroups gmane.linux.redhat.release.enigma
Message-ID <[email protected]>
Faisal wrote:

> Hi,
>
> Is there any program can replace particular value from files. Like I
> only define the path of folder and it can read each file inside the
> folder and replace it with value I define.
>
> Like I need to change company name from over 200 files htmls with new
> name how can I do that.
>
> Regards,
>
> Faisal Ashraf
> Manager Network Operations
> Silk Internet Services
>
> _______________________________________________
> enigma-list mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/enigma-list
replace.sh (application/x-sh, 280 B)
#!/bin/sh

USAGE_="usage: $0 target_directory string_to_replace new_string"

if test $# -eq 3
then

	if cd $1 
	then

		for file in *
		do
			eval perl \-pi \-e \'s/$2/$3/g\' \$file
		done

	else
		echo "Did NOT change to $1 1>&2"
		exit 1
	fi

else
	echo $USAGE_ 1>&2
	exit 1
fi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.