by aesopsalchemist · 3y ago · 0 comments
lsg () {
ls | grep $1
} alias lsg='find . -regex'edit: since I wanted to take this function or alias to start using, I looked into the differences between grep and find and seems the biggest one is that the function with grep won't include searching in subdirectories. So two possible updates, I think I'll use the second one:
lsg() {
find . -type f -name "*$1*"
}
or lsg() {
if [[ "$1" == "-r" || "$1" == "--recursive" ]]; then
find . -type f -name "*$2*"
else
ls | grep $1
fi
}