bash grep 结果到数组中 [英] bash grep results into array

查看:26
本文介绍了bash grep 结果到数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 bash 中,我试图将我的 grep 结果收集到数组中,每个单元格包含每一行.我正在用这一行下载网址

In bash I'm trying to collect my grep results in array, each cell holding each line. I'm downloaing urls with this line

wget -O index -E $CurrentURL

wget -O index -E $CurrentURL

然后我想将索引"文件结果(其他网址)grep到每个单元格的每一行中,正确的语法应该是什么?

and then i want to grep the 'index' file results (other urls) into array each line per cell, what should be the correct syntax?

Array=(grep "some expression" index)

??

推荐答案

 readarray GREPPED < <(grep "some expression" index)
 for item in "${GREPPED[@]}"
 do
     # echo
     echo "${item}"   
 done

哦,像这样组合那些 -v grep:

Oh, and combine those -v greps like so:

 egrep -v '.(jpg|gif|xml|zip|asp|php|pdf|rar|cgi|html?)'

这篇关于bash grep 结果到数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆