Reputation: 50448
In a bash script, I have a line approximately like so - which returns a multi-line response:
FILE_LIST = $(find some/path -type f )
I'd like to check whether the response contains a particular string, for example:
IF not ("filename" in FILE_LIST)
How do I perform this kind of test inside a bash script?
Upvotes: 0
Views: 58
Reputation: 9144
if echo "$FILE_LIST" |tr ' ' '\n' |grep -q "filename"
Or directly:
if find some/path -type f | grep -q "filename"
Your FILE_LIST won't work for files with spaces though.
Upvotes: 3