Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My file contains lines like this:

link type="text/css" rel="stylesheet" href="https://teststore.myproduct.com/gwtstore.css"

link type="text/css" rel="stylesheet" href="https://teststore.myproduct.com/gwtstore/downpanel.css"

.....

.....

........

script type="text/javascript" language="javascript" src="https://teststore.myproduct.com/gwtstore/gwtstore.nocache.js">

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
add comment

2 Answers

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

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
add comment

Your Answer

 
discard

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.