Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My file contains lines like this:

link type="text/css" rel="stylesheet" href=""

link type="text/css" rel="stylesheet" href=""




script type="text/javascript" language="javascript" src="">

How would I write a bash shell script that will find the 2nd and 3rd line, rename teststore as testsstore( adding s in front of store), and save it?

share|improve this question
# This is a bash script, no really!
perl -i -p -e 's/teststore/testsstore/ if $. == 2' filename
share|improve this answer

I'm not sure what you mean by "2nd and 3rd lines" as your HTML seems broken, but this sed line will replace all occurrences of "teststore" by "testsstore" in your file:

sed -i 's/teststore/testsstore/g' your_file.html
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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