Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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".
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.