我正在使用以下命令从HTML查找.js文件名。
<!DOCTYPE html>
<html>
<header>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
.MRG{ background-color:#82E0AA; }
.MRA{ background-color:#F5B041; }
.MRR{ background-color:#EC7063; }
</style>
</header>
<body>
<table class="table table-hover table-condensed" border="1px">
<thead>
<tr>
<td>Made Ready</td>
</tr>
</thead>
<tbody>
<!-- Add class name for tr -->
<tr class="changeColor">
<td>
<!-- Add id for select -->
<select id="colorChanger">
<option class="MRR">Red</option>
<option class="MRA">Amber</option>
<option class="MRG">Green</option>
</select>
</td>
</tr>
</tbody>
</table>
<!-- Add this script -->
<script>
$('#colorChanger').on('change', function() {
$('.changeColor').addClass($('#colorChanger :selected').attr('class'));
});
</script>
</body>
</html>
样本输入:
jsFiles=$(echo "$BODY" | sed -rn 's/<script\s.*src=\W(.*.js).*/\1/p')
示例输出:
<script src="a.js"></script>
<script src="b.js"></script>
<script src="c.js"></script>
<script src="d.js"></script>
现在,我要替换HTML中找到的文件名。
示例输出:
a.js
b.js
c.js
d.js
我尝试了以下方法,但是没有用。.
<script src="http://10.122.96.13./a.js"></script>
<script src="http://10.122.96.13./b.js"></script>
<script src="http://10.122.96.13./c.js"></script>
<script src="http://10.122.96.13./d.js"></script>
答案 0 :(得分:1)
请您尝试以下。
sed 's#[a-zA-Z]\.js#http://10.122.96.13./&#' Input_file