A Bash script for recursively searching files and directories matching a wildcard pattern.
This script searches for files and directories that match a given wildcard pattern through the current directory and all subdirectories, displaying full paths of matching items.
- Installation
- Usage
- Features
- Requirements
- Technical Details
- Examples
- Troubleshooting
- Contributing
- License
- Download the script:
wget https://github.com/2077DevWave/wildcard_searcher/releases/download/V1/my.sh- Make it executable:
chmod +x my.shBasic syntax:
./my.sh <wildcard_pattern>The pattern should be quoted to prevent premature shell expansion:
./my.sh "hello*"
./my.sh "*.txt"
./my.sh "test?"- Recursive search through directories
- Full path display
- Wildcard pattern matching
- Directory traversal
- Error handling
*- Matches any string of characters?- Matches any single character[]- Matches any character within brackets
- Bash shell environment
- Execute permissions on script
- Read permissions on directories to be searched
-
Input Validation
- Validates command line arguments
- Provides usage message for incorrect input
-
Pattern Handling
pattern="$1" -
Recursive Search Function
search_files() { local current_dir="$1" local pattern="$2" # ... search logic ... }
cd- Directory navigationpwd- Working directory pathecho- Output displayexit- Script termination
[ ]- Test command$#- Argument count$0- Script name$1- First argument$()- Command substitution
- Find all Python files:
./my.sh "*.py"- Find directories starting with "test":
./my.sh "test*/"Example output:
/home/user/test.py
/home/user/projects/test_dir/
/home/user/docs/testing.py
-
Permission Denied
chmod +x my.sh
-
Pattern Not Working
- Ensure pattern is quoted
- Check directory permissions
Add -x to shebang line:
#!/bin/bash -x- Case-sensitive matching
- No symbolic link following
- May be slow on large directories
- Single pattern only
- Case-insensitive search option
- Depth limit option
- Symbolic link support
- Multiple pattern support
- File size/date filters
- Fork the repository
- Create feature branch
- Commit changes
- Push to branch
- Create Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Arian Kermani - Initial work
- Bash documentation
- Shell scripting community
- Stack Overflow contributors