0

For testing purpose, I need to set up Linux command alias like this:

alias 'dmidecode -t 1'='cat ~/test/system_info'

But the alias command doesn't work like this. It seems that the alias name should be continuous characters without space. Any thought on how to achieve this? Thanks a lot and really appreciate your help!

John Kugelman
  • 330,190
  • 66
  • 504
  • 555
dibugger
  • 516
  • 5
  • 19

1 Answers1

3

Write a dmidecode() function that defers to the regular dmidecode if its arguments aren't exactly -t 1. command suppresses function lookup.

dmidecode() {
    if [[ $1 == -t && $2 == 1 ]]; then
        cat ~/test/system_info
    else
        command dmidecode "$@"
    fi
}
John Kugelman
  • 330,190
  • 66
  • 504
  • 555