2
2
20strannik082020-01-08 10:13:36
linux
20strannik08, 2020-01-08 10:13:36

How to execute a command using bash if a piece of text is successfully found in the def. file and vice versa?

Here, for example, I enter in the console: If it finds everything with the word meta, it will execute echo with the word successfully, if it does not find it, it will not execute. But how to make that in case of an unsuccessful search, force another command to be executed? For example echo "unsuccessful"? And how to organize all this in one request?
grep meta /home/1.html && echo успешно

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Germanjon, 2020-01-08
@20strannik08

grep meta /home/1.html || echo Failed
One could even
concatenate grep meta /home/1.html && echo success || echo Failed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question