Article 50HYP Alias as sudo doesn't work

Alias as sudo doesn't work

by
vinaytp
from LinuxQuestions.org on (#50HYP)
Hello All,

Hope everyone is doing good !
I am posting on this forum after really long. I have turned more of network Engineer & use less Linux these days.

I am trying to create an alias for "systemctl status network" to replace "failed" in the output to something else.

Below are the aliases created :-

Code:alias sudo='sudo '
alias systemctl='f(){ if [ $# -eq 2 ] && [[ $1 == "status" ]] && [[ $2 == "network" ]]; then systemctl $1 $2 | sed -e "s/.*failed.*/test/g" ; else systemctl $@; fi };f'If I use the command without sudo it perfectly works as shown below

Code: systemctl status network
a- network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
test
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/network.serviceBut If I use with sudo it errors out, Can someone please point my mistake ?

Code:$ sudo systemctl status network
-bash: syntax error near unexpected token `('Thanks,
Vinayalatest?d=yIl2AUoC8zA latest?i=38CuoyEWomM:EjfGJtsjsTo:F7zBnMy latest?i=38CuoyEWomM:EjfGJtsjsTo:V_sGLiP latest?d=qj6IDK7rITs latest?i=38CuoyEWomM:EjfGJtsjsTo:gIN9vFw38CuoyEWomM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments