Code:
ls | grep index.jsp | file --mime
This looks like you want the mime type of the index.jsp file. For that you could use "file --mime index.jsp".
Unless you have files of the pattern "*index.jsp". For that you can use "file --mime *index.jsp".
If the files to test have a certain pattern, you can wildcards instead of using ls or find.
file --mime dir1/*index.jsp dir2/*index.jsp *index.jsp
---
A caveat is when you have a very large number of files in the directory matching the pattern. This could cause an out-of-memory error in the shell because you exceed the maximum number of arguments. In that case, pipe find to xargs as in colucix's second example and use the -n or -L option. For your original goal of finding the mime type of
all files, you will probably want to do this.
Also, because filenames may contain white space characters, you will want to use the -print0 option to find and the -0 option for xargs:
Code:
find ./ -type f -print0 | xargs -0 -L 500 file --mime >file-mime.list