mardi 26 avril 2016

Searching within txt files using bash

I am looking trivial solution for the trivial task.

My bash script is looping several folders producing in which some log.txt file. If some operation in each case has performed successfully in each of the log the string with sentence "The unit is OK" should somewhere in the log.txt appeared, however its actual position (precise number of string) in each log.txt is differs! I need to put in my loop some condition (probably using IF ) to check whether that sentence is actually present somewhere in the log file and if so - to print "Everything is OK" within the terminal where my script is executed in moment of looping of particular folder, and otherwise (if the string is absent in the log) to print smth like "Bad news"! Will be thankful for the different solutions especially how to find the strings of selected phrases in the given log file.

Thanks!!

Gleb

Aucun commentaire:

Enregistrer un commentaire