I have a list of files like this "file1.stream_2015-02-17.mp4" that I have been deleting by time using this
#!/bin/bash
CONTENT_DIR=/my_files/recordings
find $CONTENT_DIR -mtime +1 -regextype posix-extended -regex '.*[.](mp4|tmp)$' -delete
That has been working fine for me so far but now I am trying to delete all the ones with file1.stream by 1 day and all the ones with file2.stream by 7 days
I have been trying this but I mainly keep coming up with errors
#!/bin/bash
CONTENT_DIR=/my_files/recordings/*
for f in $CONTENT_DIR; do
if [[ -f ${f} =~ 'file1.stream_*' ]] then
find -mtime +7 ${f} -delete
else
find -mtime +1 ${f} -delete
fi
done
but I keep getting this error
syntax error in conditional expression
syntax error near `=~'
` if [[ -f ${f} =~ 'file1.stream_*' ]] then'
I am not sure what the error is and I have been looking around for a few hours trying to find the syntax error. Thanks for any help