I have a hard time writing simple script using find command. I want to delete files with given size in some directory. I want to be able to specify names of files (like Efficiency_*) and size of files to delete. I tried following script:
#!/bin/bash
CD=($pwd)
find $CD -name $1 -size $2 -delete
I am running it from the correct directory as follows:
/path/to/directory/script.sh 'Efficiency_*' '-500c'
but it does not work.
What is the correct way to do it?
CD. Why are you using an array there?$pwd?set -xat the beginning so you see each command as it's being executed.find .instead offind $CD.find . -name "$1"...will work just fine :) or if you insist:CD=$(pwd); find "$CD" -name "$1"...