处理sed

编程入门 行业动态 更新时间:2024-10-21 09:17:47
处理sed-(流编辑器) - 进一步输出(Process sed-(stream editor)-output further)

我是一个bash -scripting新手,甚至不知道如何提出我的问题。 我已经浏览了本教程 ,但找不到合适的代码示例。 这就是我要的...

我有一个主机名列表( 主机名为google.com等),如下所示:

1,hostname_1 2,hostname_2 ... n,hostname_n

我想删除前面的数字,可以通过以下方式轻松完成:

originList="originList.txt" preparedList="preparedList.txt" ipv6list="ipv6list.txt" sed 's/[0-9]*,//' <$originList >$preparedList

但是我没有将输出传递给preparedList.txt而是想在我的dig命令中使用它:

sed 's/[0-9]*,//' <$originList | dig **HERE** AAAA +short >> $ipv6List

I'm a bash-scripting newbie and don't even know how to formulate my question. I've skimmed this tutorial, but couldn't find an appropriate code example. This is what I want...

I have a list of hostnames, (hostname being google.com and such), which looks like:

1,hostname_1 2,hostname_2 ... n,hostname_n

I want to remove the number in the front, that can be easily done with:

originList="originList.txt" preparedList="preparedList.txt" ipv6list="ipv6list.txt" sed 's/[0-9]*,//' <$originList >$preparedList

But instead of piping the output to preparedList.txt I'd like to use it in my dig command:

sed 's/[0-9]*,//' <$originList | dig **HERE** AAAA +short >> $ipv6List

最满意答案

用这个:

sed -e 's/^[[:digit:]]*,//' FILE | xargs -I {} dig {} AAAA +short

use this:

sed -e 's/^[[:digit:]]*,//' FILE | xargs -I {} dig {} AAAA +short

更多推荐

本文发布于:2023-07-17 13:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1144962.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:sed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!