C
C
cyberlain2022-02-24 17:10:03
linux
cyberlain, 2022-02-24 17:10:03

How to find all lines in all files with such parameters?

The task was to find all pictures either without alt, or without title, or without both. That is, you need to scan all text files and extract lines with img in them, then check if the line is missing an alt or title in it, and if the line is found, write somewhere in the listing indicating the file name and the line itself. How is this done with grep?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
ky0, 2022-02-24
@ky0

This is how it is done, in fact - by recursive grep first by img, then by the absence of something else there. Nothing complicated.

H
hint000, 2022-02-24
@hint000

for example, one file at a time:
grep img | awk '!/alt/ || !/title/'

V
Victor Taran, 2022-02-25
@shambler81

1. text file or html?
2. an example of a file in the studio.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question