Filter the output of locate not to show the Duplicates in rsnapshot
When I use locate on my server and the result is in my rsnapshot
backup then I get all those duplicates.
I could use grep to filter out all rsnapshot files:
locate something_in_backup | grep -v /var/cache/rsnapshot
but then I would miss files in the backup that are coming from other servers.
How could I filter the output to show only results from the rsnapshot/daily.0/
folder?
You can use regular expressions in the grep command:
locate something_in_backup | grep -v 'rsnapshot/\(hourly.[1-5]\|daily\|weekly\|monthly\)'
or if you don't backup hourly:
locate something_in_backup | grep -v 'rsnapshot/\(daily.[1-7]\|weekly\|monthly\)'
note the right escaping of pipe and brackets