Trying to do the following, I have txt file which as the data of the interfaces.
Eth1/15 desc01 1
Eth101/1/11 desc01 1
Eth101/1/16 desc01 1
Eth103/1/21 desc01 1
Eth1/2 desc01 1
Eth1/24 desc01 1
Eth103/1/5 desc01 1
Gi0/1 desc01 1
Gi0/0/1 desc01 1
Gi0/1/1 desc01 1
Wanted to find out the common Interface type Expected results:
If / contains twice then count the matching, else just Gi0 or Eth1
Eth1, Eth101/1, Eth103/1, Gi0, Gi0/0, Gi0/1
I tried using the AWK, what but not getting the results.
cat findint.txt | egrep 'Eth|Gi' | awk -F"/" '{print $1}'
I tried following
cat findint.txt | egrep 'Eth|Gi' | \
awk '{print substr($1, 0, length($1)-2)}' | sort -u
Results, some values are repeated which I don't.
Expected Results:
Eth1, Eth101/1, Eth103/1, Gi0, Gi0/0, Gi0/1