简体   繁体   中英

Deleting all the files under a directory using shell script, passing file directory as an argument but do not want to delete the folder itself

Sample command:

./delete.sh /path/to

|-Path 
|- to
   |- file1
   |- file2
|-location 
   |- file3
   |- file4 
   |- file5 
   . 
   . 
   |- fileN

Need to delete all the files(file1,file2,file3.....fileN) inside to and location directory using script but do not want to delete to and location directory, need to delete only files in that directory.

In delete.sh you should remove the files inside the directory

d="$1"
rm -rf $d/*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM