3 ms·
the best ones are the little ones imo lsg () { ls | grep $1 }
by aesopsalchemist 3y ago
the best ones are the little ones imo
lsg () {
ls | grep $1
}
- GhostWhisperer 3y agoit need not be a function, but also: alias lsg='find . -regex'
- swores 3y agoBut that then requires using regex each time? So if there's a file I'm looking for called test.txt I could run "lsg test" and find it using their function but fail to find it using this alias? Or am I mistaken, I'm hardly an expert. 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 }