I'm trying to learn Bash scripting. when i use the command directly in the bash
find . -xdev -type d -path ./sys -o -path ./proc -o -path ./run -prune -o -iname "*.txt"
This gives me a buch of results while
But when I use the same code in a script file
#!/bin/bash
shopt -s extglob
find . -xdev -type d -path ./sys -o -path ./proc -o -path ./run -prune -o -iname "$1"
~
Gives me only one result.
PS: Don't take the extglob seriosly I was trying to do it with parentheses.
Tried to add shopt -s extglob, tried different variants of code. Command with parentheses didn't work even when I added shopt -s extglob
Created a file named "bul" and put the code inside, chmoded it with +x and put the file in ~/.local/bin where i want to run directly from my terminal(I have the path in my .bashrc)
I removed shopt -s extglob from the code,
I have text.txt file in my home folder and 2 .txt files in my ~/Documents/ folder. It's only finds the file in the home folder. where i search from. Even when i it must start searching from / root.
EDIT: When i search directly from terminal with command:
find . -xdev -type d '(' -path './sys/*' -o -path './proc/*' -o -path './run/*' ')' -prune -o -name *.txt -print
It's gives me the correct result.
But when i run it wild wildcard with command bul . *.txt
it's give me the result:
+ find . -xdev -type d '(' -path './sys/*' -o -path './proc/*' -o -path './run/*' ')' -prune -o -name text.txt -print
It's searching "text.txt"
SOLVED: When i type the command in terminal like "bul . .txt" it doesn't work but when i qouted second argument 'bul . ".txt"' like this it works.
Thank you all for your help.