I am guessing I am overlooking something simple, since this seems like it should be a very straightforward task, but I am coming up short and can't seem to find anything on forums.
I am trying to run find from within a shell script and it is just not doing anything.
For example, I have a folder, with some files and a couple subdirectories with files as well:
$ ls *
afile1.txt anotherfile.py findit.sh
subdir1:
morefiles1.txt morefiles2.txt morefiles3.txt somescript.py
subdir2:
evenmorefiles1.txt evenmorefiles2.py evenmorefiles2.sh
I want to use find to pull out all filenames with a given search string (and ultimately pipe to xargs), but I cannot seem to figure out why the exact same command works from the command line but not from within the shell script:
$ cat findit.sh
#!/bin/bash
echo $(which find)
echo "find . -name '"$1"' -print0"
find . -name '"$1"' -print0
echo "nothin??"
$ . findit.sh '*py'
/usr/bin/find
find . -name '*py' -print0
nothin??
$ find . -name '*py' -print0
./anotherfile.py./subdir2/evenmorefiles2.py./subdir1/somescript.py
I appreciate any help on this front...
'"$1"')