Gi1/0/12
Gi1/0/13
Gi1/0/14
Gi1/0/15
Gi1/0/16
Gi1/0/17
Gi1/0/18
Gi1/0/19
Gi1/0/20
Gi1/0/21
Gi1/0/22
Gi1/0/23
Fa2/0/13
Fa2/0/14
Fa2/0/15
Fa2/0/16
Fa2/0/17
Fa2/0/18
Fa2/0/19
Fa2/0/20
Fa2/0/21
Fa2/0/22
Fa2/0/23
Fa2/0/24
Gi2/0/1
I want to parse this data so that
I can have the no of
regexvalue start end count
Gi1/0/ 12 23 12
Fa2/0/ 13 13 12
Gi2/0/ 1 1 1
NOTE:regex value could be changing like instead of Gi it could be te or instead of Gi/0/ it could be Gi/1 or Gi/10.but the format reamains same.
this is how i just did it using sed first and then awk:
sed 's/\(.*\/\)\(.*\)/\1 \2/g'
#!/bin/bash
awk '
{
a[$1]++
if ( a[$1] == 1 )
{
inte[$1]=$2
}
}
END {
for (var in inte)
print var,inte[var],a[var]
}
'
output :
Fa2/0/ 13 12
Gi1/0/ 12 12
Gi2/0/ 1 1
awkis the typical tool for that) and come back here with specific problem you encounter on the way. – Stephane Chazelas Mar 13 at 7:14