Учитывая, что ваш фактический файл Input_file будет таким же, как и в показанных примерах, не могли бы вы попробовать следующее.
awk '
BEGIN{
FS=OFS=","
}
match($0,/\/\/.*\.com:[0-9]+/){
val=substr($0,RSTART+2,RLENGTH-2)
sub(/:/,",",val)
print val
next
}
match($0,/\/\/.*\.com[^/]*/){
val=substr($0,RSTART+2,RLENGTH-2)
print val,$NF
}
' Input_file
Объяснение: Добавление подробного объяснения выше.
awk ' ##Starting awk program from here.
BEGIN{ ##Starting BEGIN section from here.
FS=OFS="," ##Setting FS and OFS as comma here.
}
match($0,/\/\/.*\.com:[0-9]+/){ ##Matching from // to till .com digits then if match found then do following.
val=substr($0,RSTART+2,RLENGTH-2) ##Creating val which has sub-string of matched value above.
sub(/:/,",",val) ##Substituting colon with comma here in val.
print val ##Printing val here.
next ##next will skip all further statements.
}
match($0,/\/\/.*\.com[^/]*/){ ##Matching from // to .com here, followed by /
val=substr($0,RSTART+2,RLENGTH-2) ##Creating val which has sub-string of current line.
print val,$NF ##Printing val and last field here.
}
' Input_file ##Mentioning Input_file name here.