1.写个jsp页面,代码如下
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); out.println("张三"); out.println("李四"); out.println("张三"); out.println("张三"); %>
2.用shell脚本调用jsp页面,把结果存成文件/tmp/test.html
wget -O/tmp/test.html "http://www.baidu.com"
3.然后再用shell读取/tmp/test.html分析返回结果
cat /tmp/test.html
4.分析有多少个张三
cat /tmp/test.html | grep 张三 | wc l
输出结果
3