Hi,
I am writing a script using find command to search for particular files in a directory and delete the files.
The directory structure is like this - /home/load and /home/load/processed.
The files are named as *.pass files and it is present in both /home/load and /home/load/processed directory.
I want to delete the *.pass files only in /home/load directory and not from the subdirectory processed.
The script I have written deletes in both /home/load and /home/load/processed directory.
Following is my script.
#!/bin/sh
RPT_TO=/home/load
cd ${RPT_TO}
for myFile1 in $(find . -name "*.pass"
; do
echo $myFile1
rm ${myFile1}
done
How do I prevent it from deleting from the sub-directory.
Please provide me with any ideas.
I appreciate all your help.
Thanks in advance.
I am writing a script using find command to search for particular files in a directory and delete the files.
The directory structure is like this - /home/load and /home/load/processed.
The files are named as *.pass files and it is present in both /home/load and /home/load/processed directory.
I want to delete the *.pass files only in /home/load directory and not from the subdirectory processed.
The script I have written deletes in both /home/load and /home/load/processed directory.
Following is my script.
#!/bin/sh
RPT_TO=/home/load
cd ${RPT_TO}
for myFile1 in $(find . -name "*.pass"
echo $myFile1
rm ${myFile1}
done
How do I prevent it from deleting from the sub-directory.
Please provide me with any ideas.
I appreciate all your help.
Thanks in advance.