(SOLVED) Problem creating bashrc alias

Forum rules
Before you post please read how to get help
Post Reply
User avatar
Larry78723
Level 7
Level 7
Posts: 1546
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

(SOLVED) Problem creating bashrc alias

Post by Larry78723 » Mon Oct 07, 2019 9:19 am

I'm trying to create a bashrc alias as

Code: Select all

alias jerr="journalctl -b| grep -e error -e warn -e fail"
. I inserted it in the

Code: Select all

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    alias errors="journalctl -b -p err|less --color=auto"
    alias jerr="journalctl -b|grep -e error -e warn -e fail"
fi
section
When I type "jerr" in a terminal I get "jerr: command not found". Can somebody tell me what's wrong with the syntax?

Thanks in advance,
Larry
Last edited by Larry78723 on Mon Oct 07, 2019 10:08 am, edited 1 time in total.
Image

Pippin
Level 4
Level 4
Posts: 291
Joined: Wed Dec 13, 2017 11:14 am
Location: NL/DE/TH

Re: problem creating bashrc alias

Post by Pippin » Mon Oct 07, 2019 9:30 am

I use .bash_aliases, all aliases in a separate file.

To load new aliases without reboot

Code: Select all

. .bash_aliases
Instead of . can also do

Code: Select all

source .bash_aliases
Example:

Code: Select all

alias df='df --sync -hT'
Everything is electric.

User avatar
Larry78723
Level 7
Level 7
Posts: 1546
Joined: Wed Jan 09, 2019 7:01 pm
Location: Jasper County, SC, USA

Re: problem creating bashrc alias

Post by Larry78723 » Mon Oct 07, 2019 10:08 am

Thanks Pippin, that worked great!
Image

Post Reply

Return to “Scripts & Bash”