0

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?

2 Answers 2

1
#!/bin/bash
#
# This is a bash script, no really!
#
perl -i -p -e 's/teststore/testsstore/ if $. == 2' filename
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .