get-file-list-by-word.sh

Get a list of filenames containing a specific word.

While traversing the json files in the folder, print out if there is a file containing "WOOL".

bash

# !/bin/bash
for filename in ./*.json; do
    if grep -q "WOOL" "$filename" 
    then
        echo $filename
    else
        rm -rf $filename
    fi
done