Entropic Ninja
Entropic Ninja

Reputation: 93

How To use grep in a chain as an alias

cdl ()   
{  
   cd $1  
   ls
}

So I use the above in my bash_aliases file by running cdl /lib/systemd/systemd.

My question is how can I add grep to this. I'd like to be able to do something like cdl [/path] [grep query]

maybe something like

cdlg ()   
{  
   cd "$1"
   ls | grep -ni
}

Upvotes: 1

Views: 147

Answers (1)

Tyhal
Tyhal

Reputation: 789

cdlg ()   
{  
   cd "$1"  
   ls | grep -ni "$2" -
}

Upvotes: 1

Related Questions