Background:
There is a source package that contains many subdirectories and makefile, and the packed package is too large to be deleted and then packaged by all the binaries created by make.
Demand:
Therefore, make clean is required to clear all the target files in all the recursive subdirectories of the catalog.
Code:
Wrote a simple shell script with two features:
1. Traverse all subdirectories and execute make clean if there is makefile (more can be done, of course);
2. list files in all subdirectories that are larger than 10M (and of course you can specify other values).
Words not much to say on the code:
#!/bin/Bashrun_make () {#如果该目录下存在Makefileif[-F"Makefile"]; Then Echo "" Echo===================== FOUND ===================pwd; Echo=============================================== MakeClean ; fi}run_ls () {pwd; #列出大于10M的文件 #ls-L |awk '{if ($ > 10485760) {print $}}' ls-L |awk '{if ($ > 10485760) {print "--", $9,$5}}' Echo ""}myfunc () {CD $1; #run_make; Run_ls; forXinch$(ls .) Do if[-D"$x"]; ThenMyFunc $x; Cd.. fi Done}p=.if[ $1]; ThenP=$1fiEcho$pmyfunc $p
The shell traverses the folder and executes the command