I’m trying to write simple bash script and I’m stuck with find command.
When I type find . zad*, I get output like:
.
./lab2.sh~
./#zad2.sh#
./zad2.sh~
./zad1a.sh
./zad2.sh
./lab2.sh
./Azad2.sh~
./cdlinux.ftp.log
./Azad2.sh
./zad1a.sh~
./zad1.sh
./cdlinux.www.log
./zad1.sh~
zad1a.sh
zad1a.sh~
zad1.sh
zad1.sh~
zad2.sh
zad2.sh~
Why does it list all files in my folder (with ./ before file name), and after that I get proper find results. Is there any way to remove that ./ output? Using sed command won’t work in all cases (when search path would be different than .).
You have to use
-nameflag to specify the name to search for, and enclose the pattern in quotes so bash doesn’t perform automatic expansion on the wildcard*before it’s passed tofind:Also, you don’t need to specify the cwd path with
.Using:
should work just fine =)