我对sed / bash有点新意,我试图从这个地址中提取url(基本上是.com的/ .infos / xyz)基本上抓住“”中的域并输出到新文件中
来源:
(window,arguments);})(2,340000,625803,"domain.com",7,3,0,1200,"anotherdomain.info",0,[],1,[],[],false,"sdfs-fdsf",0 "remove_file_ext":true,"mode":"sector","sector":".dlitre"},"domain.xyz",5,0.4,0.8,[],0,"//vghvghv.
期望的输出:
domain.com
anotherdomain.info
domain.xyz
答案 0 :(得分:0)
您能否请关注awk
并告诉我这是否对您有所帮助。
awk '{while(match($0,/"[^"]*/)){val=substr($0,RSTART+1,RLENGTH-1);if(val ~ /com|info|xyz/){print val};$0=substr($0,RSTART+RLENGTH+1)}}' Input_file
现在也添加非单线形式的解决方案。
awk '
{
while(match($0,/"[^"]*/)){
val=substr($0,RSTART+1,RLENGTH-1);
if(val ~ /com|info|xyz/){ print val };
$0=substr($0,RSTART+RLENGTH+1)}
}
' Input_file