Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Here is my problem statement :

There is a folder with many html and text files. I need to recursively go through each one of them and find all kinds of file extensions referenced in these html/text files like .jpg, .tif, .png etc

The problem is I don't have a defined list of the extensions I want to search for.

What would be the best way to achieve this using a shell script ?

Coming up with a Reg-ex which would essentially search for all occurrences of a dot followed by 3 or 4 letters, and filtering out the ones which end with a space or a comma, or a quote etc ??

Any suggestions would be helpful.

share|improve this question

1 Answer 1

Keeping in mind that HTML is not a regular language, you could probably at least narrow it down with:

grep -Ro '[a-zA-Z0-9]+\.[a-zA-Z0-9]{1,4}' *
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.