How Do I Find a Specific File Extension in Unix?
Contents

How do you find the file extension in Unix?

filename=`basename $filepath` fileext=${filename##*.} By doing that I can get extension of bz2 from the path /dir/subdir/file.

How do I search for a file with a specific extension?

For finding a specific file type, simply use the ‘type:’ command, followed by the file extension. For example, you can find . docx files by searching ‘type: . docx’.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest