give sudo permission to log files on different paths like /a/b1/c.log and /a/b2/d.log etc. files

118 Views Asked by At

I need a nice column for Centrify tool which include all the log files under the different folders, for example;

/oradata1/oracle/admin/A/scripts/rman_logs/*.log

/oracle/oracle/admin/B/scripts/rman_logs/*.log

/oradata2/admin/C/scripts/logs/*.log

I used this but after the * character user can see all logs; /ora(data(1|2)|cle)/oracle|admin/admin/*/scripts/rman_logs

/ora(data(1|2)|cle)/oracle|admin/admin/*/scripts/rman_logs

Which expression I must use.

2

There are 2 best solutions below

0
On

I have found a global expression.

this is not a good way but it works and save me from lots of job. The main files are under the ....../scripts/rman_logs/ for all servers so I use this way.

I can produce these lines and can be a command group for users so this works good

tail /////scripts/rman_logs/*.log

tail ////scripts/rman_logs/.log

Thanks for your helps.

3
On

If I understandy our question correctly, you want only .log files. You can use a positive lookahead to assert that it is indeed a log file (contains .log at the end of filename), and match the filename whatever it is (.*).

Then it's really easy. (?=.*\.log(?:$|\s)).* Of course, you can also add specific folders if you wish to restrict the matches, but the positive lookahead will still do its work. I.e. (?=.*\.log(?:$|\s)).*/scripts/.*

EDIT: As your comment, you only need those folders, so you just specify their filepaths in alternations and add [^.\s\/]*\.log at the end. So:

(?:\/oradata1\/oracle\/admin\/A\/scripts\/rman_logs\/|\/oracle\/oracle\/admin\/B\/scripts\/rman_logs\/|\/oradata2\/admin\/C\/scripts\/logs\/)[^\s.\/]*\.log You may shorten the regex by trying to combine filepath elements, but, imo, not necessary as you might as well specify each filepath individually, if they don't overlap too much.