Reputation: 41
Sample command:
./delete.sh /path/to/location
|-Path |-to |-location |- file1 |- file2 |- file3 . . |- fileN
Need to delete all the files(file1,file2,file3.....fileN) inside location directory using script
Upvotes: 0
Views: 2351
Reputation: 12917
Use the find command for this:
find "$1" -maxdepth 1 -type f -delete
Pass the directory as a parameter in the scripts ($1) and then ensure you are only searching the directory at one level with -maxdepth 1 and searching for files only with -f. Delete what ever is found with -delete.
Upvotes: 1