首页 > 解决方案 > 如何在链中使用 grep 作为别名

问题描述

cdl ()   
{  
   cd $1  
   ls
}

所以我通过运行在我的 bash_aliases 文件中使用上述内容cdl /lib/systemd/systemd

我的问题是如何添加 grep 。我希望能够做类似的事情 cdl [/path] [grep query]

也许像

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

标签: linuxbashaliasaliases

解决方案


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

推荐阅读