Delete all files in particular directory
I want to find a files compile.logs that older than 90 days in /compile directory this can be achieved by using below command
find /compile -mite +90 -name "compile.logs" and i get out like this /compile/home/bob/work/para/build.ntb/compile.logs /compile/home/meta/work/mac/eth/build.ntb/compile.logs /compile/home/meta/work/core/qlo/hba/ds-x/port1/build.ntb/compile.logs Now please advice how to delete all the files after build.ntb directory |
RTFM
Man page for find mentions -delete option.
Use with care. |
Might depend on how you define "all" in the following - "how to delete all the files after build.ntb directory".
And, of course, which "build.ntb directory". |
check it shown the exact dated files then move for deleted before delete check whether you are able to see the older logs
find /compile -type f -mtime +90 -name "file.log" -exec ls -lrt {} \; |
Hi
I wrote script to find the files which older than 80 days and file name contains compile_dut.log output should be like below /compile/home/bob/work/para/build.ntb/compile_dut.log /compile/home/meta/work/mac/eth/build.ntb/compile_dut.log /compile/home/meta/work/core/qlo/hba/ds-x/port1/build.ntb/compile_dut.log and i want to delete all the files under (that is what are the files along with compile_dut.log) /compile/home/bob/work/para/build.ntb/ /compile/home/meta/work/mac/eth/build.ntb/ /compile/home/meta/work/core/qlo/hba/ds-x/port1/build.ntb/ Please verify my script and let me know any changes required here #!/bin/sh #find the files which older than 80 days and file name contains compile_dut.log find /dv4 -mtime +80 -name 'compile_dut.log' > /dv4/80days.txt #Remove 15 chars in path while read line do echo -e "$line" | sed 's/.\{15\}$//' >> /dv4/delete-dv4.txt done < /dv4/80days.txt #Go to specified directory and delete all the files while read line do cd $line rm -rf * done < /dv4/delete-dv4.txt rm -f /dv4/80days.txt rm -f /dv4/delete-dv4.txt |
Try this:
Code:
#!/bin/bash |
All times are GMT -5. The time now is 12:24 PM. |