Recursively look for files with a specific extension
find $directory -type f -name "*.in"
is a bit shorter than that whole thing (and safer - deals with whitespace in filenames and directory names).
Your script is probably failing for entries that don't have a .
in their name, making $extension
empty.
find {directory} -type f -name '*.extension'
Example: To find all csv
files in the current directory and its sub-directories, use:
find . -type f -name '*.csv'
The syntax I use is a bit different than what @Matt suggested:
find $directory -type f -name \*.in
(it's one less keystroke).
Without using find
:
du -a $directory | awk '{print $2}' | grep '\.in$'
find "$PWD" -type f -name "*.in"