search in subdirectories for all html files containing the tag

发布时间:2026-02-27 07:33

'Apology'用'My apologies for the delay'致歉 #生活技巧# #职场沟通技巧# #商务英语口语#

This question shows research effort; it is useful and clear

2

Save this question.

Show activity on this post.

I have a directory include many files of different extensions. What I want is to list all .html files only that contains the tag .

asked Jun 13, 2015 at 13:46

Maythux's user avatar

This answer is useful

5

Save this answer.

Show activity on this post.

From the terminal, use the find command to find all the files ending in .html and use the grep command to filter the results to show only the names of files that contain the <abbr> string:

cd /path-to-dir ## change directories to the root directory that you are searching from find . -name "*.html" -exec grep -l '<abbr>' {} +

The find command searches for files in a directory hierarchy recursively by default.

Or combine the two commands into a single command:

find /path-to-dir -name "*.html" -exec grep -l '<abbr>' {} +

answered Jun 13, 2015 at 14:06

5

This answer is useful

1

Save this answer.

Show activity on this post.

A simple solution:

grep -r "<abbr" --include="*.html" /path-to-dir use -r for all subdirectories. Use --include='*html' to match html files only.

answered Jun 13, 2015 at 13:52

Maythux's user avatar

This answer is useful

0

Save this answer.

Show activity on this post.

For verification (namely, the file name and the lines with <abbr>), you may use a simple:

grep '<abbr>' /path-to-dir/*.html

If you want file names only, use the following:

grep '<abbr>' /path-to-dir/*.html | awk -F: '{ print $1 }' | sort | uniq

answered Jun 14, 2015 at 20:37

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

网址:search in subdirectories for all html files containing the tag https://klqsh.com/news/view/344079

相关内容

6 Examples to Find Files in Linux with Find Command
How to find file in Linux
How to Use the Linux find Command to Locate Files Like a Pro
Microsoft Search in Bing and Microsoft 365 Apps for enterprise
Find your files in Windows
Learn to use Bing search operators
How To Get Help In Windows 11 (All Methods)
Get Help With File Explorer in Windows 11 & 10 (Ultimate Guide)
Introducing Copilot Search in Bing
The next step in Bing generative search

随便看看