Here is a very short find command to find all Fortran related files. The most common Fortran files are *.f
, *.f90
, and their capital letter counterparts. Additionally, .f95
, .f03
, .f08
, and even .for
are used. Note that -iregex
matches the regular expression case insensitive (in contrast to -regex
).
find . -iregex ".*\.F[0-9]*" -o -iregex ".*\.for"
To do something with this, you can use xargs
:
find . -iregex ".*\.F[0-9]*" -o -iregex ".*\.for" | xargs head -1
Replace head -1
with whatever you want to do with the files.
Another way to work with that is using a loop such as:
for file in $(find . -iregex ".*\.F[0-9]*" -o -iregex ".*\.for"); do
head -1 "$file"
done
This gives you a bit more flexibility than the xargs
approach, and is easier to read.