3 ms·
it need not be a function, but also: alias lsg='find . -regex'
by GhostWhisperer 3y ago
it 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 }