Thursday, 5 March 2020

Access data from file in linux scripts

instead of search for one particular word line by line in file using the below command in scripts

In manual way of running Linux command, more command is useful to search for key word.

The follow method can be used to search for a key word in file in script point of view.

  1. To grep error messages from log file.
                  grep -i error /usr/sap/sid/work/dev_disp.log
      2.To grep warming messages from log file.
                 grep -i warning /usr/sap/sid/work/dev_disp.log
      3. To grep  for fail  key word in the file.
                grep -i fail /usr/sap/sid/work/dev_disp.log


Output to file:To send output  of above cmd to one file use syntax as below:



grep  -i error /usr/sap/sid/work/dev_disp.log > /install/error.log

No comments:

Post a Comment