cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
967
Views
0
Helpful
6
Replies

NEXOS Sort command key

Zeroedin
Level 1
Level 1

Hello,  I have a switch with nxos.9.3.1 and I am trying to sort the "show mac address-table" output by the interface. I have the command "show mac address-table | i Eth | sort -k" so far and wanted to know how I could use the -k as I was not able to find any documentation about it. Do I have to convert it to JSON first? Is there some specific documentation that could help me with this issue?

This is an example output:

* 3000 aaaa.aaaa.aaaa dynamic 0 F F Eth1/1

 

Thank you

6 Replies 6

balaji.bandi
Hall of Fame
Hall of Fame

-k field-number[.char-position][ordering]

Sorts according to a key value. There is no default key value.

I was not sure what is the outcome you expecting :

here is document for sort usage.

https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/7-x/fundamentals/configuration/guide/b_Cisco_Nexus_9000_Series_NX-OS_Fundamentals_Configuration_Guide_7x/b_Cisco_Nexus_9000_Series_NX-OS_Fundamentals_Configuration_Guide_7x_chapte...

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

I saw this exact documentation but I don't understand too well. What is "field-number" and [.char-position][ordering] in relation to what I needed to be sorted. The documentation doesn't explain too well.

Post the full output of your show command / what you want to sort with -K ?

the example show output you posted on original post not help since its single value.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

If I have the output of a "show mac address-table" such as this:

* 3000     0010.8683.6422   dynamic  0         F      F    Eth1/4
* 3000     0050.5685.0142   dynamic  0         F      F    Eth1/1
* 3000     0050.5685.098c   dynamic  0         F      F    Eth1/1
* 3000     0050.5685.3d7c   dynamic  0         F      F    Eth1/1
* 3000     0050.5685.51c3   dynamic  0         F      F    Eth1/2
* 3000     0050.5685.761d   dynamic  0         F      F    Eth1/2
* 3000     0050.5685.a0e5   dynamic  0         F      F    Eth1/1
* 3000     0050.5685.b423   dynamic  0         F      F    Eth1/1
* 3000     0050.5685.b8d9   dynamic  0         F      F    Eth1/2
* 3000     0050.5685.bc2a   dynamic  0         F      F    Eth1/3
* 3000     0050.5685.c727   dynamic  0         F      F    Eth1/2
* 3000     0050.5685.d73e   dynamic  0         F      F    Eth1/1
* 3000     0050.5685.e499   dynamic  0         F      F    Eth1/1
* 3000     0050.5685.eb9a   dynamic  0         F      F    Eth1/3
* 3000     0050.cca3.2510   dynamic  0         F      F    Eth1/49/1
* 3000     0050.cca3.2513   dynamic  0         F      F    Eth1/49/1
* 3000     0050.cca3.2810   dynamic  0         F      F    Eth1/49/2
* 3000     0050.cca3.2813   dynamic  0         F      F    Eth1/49/2
* 3000     0050.cca3.2f7e   dynamic  0         F      F    Eth1/49/4
* 3000     0050.cca3.2f81   dynamic  0         F      F    Eth1/49/4
* 3000     0050.cca3.32a8   dynamic  0         F      F    Eth1/49/3
* 3000     0050.cca3.32ab   dynamic  0         F      F    Eth1/49/3

 Could I use -k to sort by interface? I am not really sure how it works.

not that you can do that with sort in the box - may be get the information out of the box and process using Python is best option, you can look below example :

https://developer.cisco.com/docs/nx-os/#!example-scripts/example-deltacounterspy

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

What you need exactly?

You want to know meaning of -K