0

I have a set of log files and I need to find tables from a specific database being used by searching them in log files. The search keyword should start with 'database.' and should be able to grep/parse all table names with preceding database name. Can anyone advise on how this can be achieved using shell script.

Thanks

2
  • Please include a sample of an input file. Show what output you expect for the sample. Commented Jan 12, 2022 at 14:48
  • You have to be more specific. Otherwise the answer is: yes use grep. Commented Jan 12, 2022 at 14:50

1 Answer 1

1

This is very easy:

grep "database" *              : this shows the filename + the entire line
grep -l "database" *           : this shows only the filename
grep -o "database [a-z]*" *    : this shows the filename + the database name
grep -h -o "database [a-z]*" * : this shows the database name
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.