ā09-22-2023 11:12 AM
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
ā09-23-2023 02:18 AM
-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.
ā09-23-2023 07:30 PM
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.
ā09-24-2023 12:26 AM
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.
ā09-25-2023 06:26 AM
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.
ā09-25-2023 07:25 AM
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
ā09-23-2023 03:02 AM
What you need exactly?
You want to know meaning of -K
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide