11/29/2018

Arista Linux Essential (2)

Useful Utilities
  • Date/time
    • date +%Y%m%d-%H%M%S
    • Epoch - Linux born time
  • Sort
    • du -s /var/* | sort -n
    • -n: numeric order
  • Cut
    • cut -d: -f:1,6 /etc/password
    • -c: cut columns
  • Diff:
    • Cli -p15 -c "show run" | diff -y -w -B --suppress-common-lines - /mnt/flash/startup-config
    • -B --ingore-blank-lines
    • -y --side-by-side
    • -w --ignore-all-space
  • regexp:
    • greedy vs lazy, ? at the end of pattern
  • grep = global reg exp print
    • -i: ignore case
    • -v: inverse, not-matching
    • -A: print # lines AFTER matching
    • -B: print # lines BEFORE matching
  • sed = powerful stream editor
    • remove quotes: sed -e 's/"//g'
    • reverse ip address:
      • echo "10.20.30.40" | sed -e 's/\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)/\4.\3.\2.\1/'
      • reverse A-record to fwd record
  • awk
    • awk -F: '{print $1, $6}
    • alias shmc show int | awk '/^[A-Z]/ { intf=$1 } 
  • tar
    • tar czvf config.1.gz config.1

[admin@bn303 etc]$ Cli -p15 -c "show run" | diff -y -w -B --suppress-common-lines - /mnt/flash/startup-config
! Command: show running-config        | ! Startup-config last modified at  Wed Nov 28 17:01:44 2018 b
! device: bn303 (DCS-7512N, EOS-4.20.1F)       | ! device: bn303 (DCS-7512N, EOS-4.20.10M)

No comments:

Post a Comment