0

I'm working on a project where I'm to replace Lorem Ipsum with relevant text in web template files. Unfortunately, it's identical Lorem Ipsum text throughout all files, and the correlation between a screen and its generating template isn't easy to make. In other words, when I see "Lorem Ipsum ..." on a particular page, I don't have an easy way to tell which template generated it, even considering all other information on that page.

I want to replace all Lorem Ipsum over several files with a uniquely identifying string in all of the templates. Something like "Lorem Ipsum 1", "Lorem Ipsum randomStringHere" etc. That way, I can look at a page and grep to find the corresponding template.

I use this perl one-liner to find and replace in multiple files

perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt

But I don't know how to change it to do the uniquely identifying string. Hopefully something without too much development.

0

I was able to use this solution like so:

find . -type f -exec perl -pi -e 's/ipsum/join "", map { ("a" .. "z", "A" .. "Z", 0 .. 9)[rand(62)] } 1 .. 64/eg' {} \;

and I get strings like Lorem 1S1MWLSNys0eVhjVREMLRWaZFPSqPXy0bwjaXgXxluU8pajf4v6NbnPXjXTW5rdf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.