I'm trying to create a simple script that deletes files based on the ending of thier names and the date.
I can't figure out how to do this.
This is how I do it:
DA='date +%d'
find /var/www/data/files/ -name "*#$DA*"
I want to find all files that ends on this pattern.. So today it would be #06
I also tried
find . -iname \*${MYVAR}\* -print
As suggested here:
http://www.commandlinefu.com/commands/view/6234/use-a-variable-in-a-find-command.-useful-in-scripting.
Without luck..
So can anyone help me use the find command searching for a var?
Thanks a lot!
Best Answer
This should do the trick. With
$()
You can get the output of a command as an argument to another command.