21 Feb 2019

Find files script

I can never remember the correct format of the find command so that I can recusively search through folders for a particular file or files. So I set up a scripts folder in my user folder and added it to my path in my .bash_profile, and created this text file:

1
2
#!/bin/bash
find . -name $@

The $@ paramater is a placeholder that passes a variable number of arguments from the commandline onto the line with find on it, so you can add more paramaters if you need to. Then give this file a suitable name (findfiles is what I’ve called mine), place it the scripts folder mentioned above, and don’t forget to mark the script as executable:

1
2
chmod +x findfiles
findfiles myfile.ext
comments powered by Disqus