1

So, I have a requirement to delete all files from specific folders within a directory. These are folders that end with "-outputs" in their names and I need to delete all files in those particular folders.

Is there a command in linux that lets you do that?

1 Answers1

2

You can execute the following command:

rm $YOUR_PATH\*-outputs

Change $YOUR_PATH to the path where the files are located.

If you want to ignore nonexistent files and arguments, and avoid the prompt, you can use the -f option.

rm -f $YOUR_PATH\*-outputs

You can see the different rm options here: rm Linual manual page

ivasanpag
  • 149
  • 1
  • 4
  • I don't want to delete the folders themselves. Just the files inside those folders. This will delete the folders as well right?! – Coding_N00b Nov 10 '21 at 11:08
  • If you don't use the -r option, rm will only delete the files inside a directory. https://stackoverflow.com/questions/7714900/remove-only-files-in-directory-on-linux-not-directories – ivasanpag Nov 10 '21 at 11:15