Skip to content
Advertisement

bash script version of forfiles

I’m currently converting a DOS batch script to a shell script and while I have 99% of it working, one part I cannot figure out how to convert over.

In the batch file, I have a line that looks like

forfiles -p "t:jeopardy" -s -m *.* /D -3 /C "cmd /c del @path"

How would I write that for a shell script?

Advertisement

Answer

Try this, this will delete files without prompting

find /jeopardy -mtime 3 -name "*.*" -exec rm -f {} ;

To be prompted before files are deleted, try the variation of above

find /jeopardy -mtime 3 -name "*.*" -exec rm -i {} ;

NOTE: I have used the Linux variant of the path t:jeopardy

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement