Answer the question
In order to leave comments, you need to log in
Is it possible to use a regular expression in the tail command to search for matching files and not lines in them?
There are many examples on the net on how to extract the necessary information from the logs found using the tail command using a regular expression.
But I'm wondering if it's possible to do something more than select all files in the path that have *
Source data:
- There are 2 files in the directory with a special label in the name => my_company
- /var/log/containers/user-sync-service-54d7487d98-rxx8p_my_company_user-sync-service-fee158b16774f94221d2e7e652042aa905444cf34b333e0c1f6b0638ae2e85f9.log
- /var/log/containers/kube-gelf-2rcf4_my_company_agent-50798dc1c159b1ff75d00ba4f3b12af752093c69b1ada2067527caefbed0adc2.log
Answer the question
In order to leave comments, you need to log in
- something like this happened, it's not beautiful, but it works
find . -regex ".*my_company.*" ! -regex ".*my_company_\(agent\).*\.log" | xargs tail
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question