Results 1 to 2 of 2
Hey guys,
Im trying to write a script that uses a loop to generate a list of certain files. I've got files that end with .csv and files that end ...
- 07-14-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 1
Script that Loops and searches for a specific file
Hey guys,
Im trying to write a script that uses a loop to generate a list of certain files. I've got files that end with .csv and files that end with .dat. I would also like it to delete the files one at a time. I hope I can get some help with this script, im still very very new in Linux.
Thanks for your replies.
- 07-14-2009 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
You can accomplish this with one command called 'find' as follows:
The '.' after find means search the current directory. Replace the dot with the directory you want to search. The '-i' option for the rm command means it'll prompt you as to whether to delete the file or not.Code:find . -maxdepth 1 -type f \( -name "*.csv" -o -name "*.dat" \) -exec rm -i {} \;


Reply With Quote