w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Find all directories containing a file that contains a keyword in linux

Maybe you can try this:

grep -rl "OPEN" . --include='STATUS.txt'| sed 's/STATUS.txt//'

where grep -r means recursive , -l means only list the files matching, '.' is the directory location. You can pipe it to sed to remove the file name.

You can then wrap this in a bash script file where you can pass in keywords such as 'OPEN', 'FUTURE' as an argument.

#!/bin/bash
grep -rl "$1" . --include='STATUS.txt'| sed 's/STATUS.txt//'




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.