Script to recursively copy and rename files with find and sed
bash |copy code |?
1 find aber/cs25010/ -iname "*.txt" -printf 'cp %p %p\n' \2 | sed 's/\.txt$/\.php/' \3 | while read l; do eval $l; done
Script to recursively copy and rename files with find and sed
bash |copy code |?
1 find aber/cs25010/ -iname "*.txt" -printf 'cp %p %p\n' \2 | sed 's/\.txt$/\.php/' \3 | while read l; do eval $l; done
Loop files under a set weight to move it to a directory.
bash |copy code |?
1 for f in `find . -iname "*.JPG" -size -500k`; do mv ${f} small; done
How to make a regexp search with find recursively . If you want to search only in php files, replace file_pattern with “*.php”
bash |copy code |?
1 find . -iname-exec grep -n
Find files and directories containning your search terms, and delete them witout confirmation and recursively. No matter if they are not empty.
bash |copy code |?
1 find . -name "search_terms" -exec rm -rf {} \;
A bash command to search for all hidden files recursively in the current directory but ignore apache .htaccess files.
bash |copy code |?
1 find . -type f \( -iname ".*" ! -iname ".htaccess" \)
Recursively search all files matching a regexp in the current directory and then listing them.
bash |copy code |?
1 find . -type f -name "*.file" | xargs grep -l "STRING"
This could also be done like this:
bash |copy code |?
1 find . -type f -name "*.file" --exec grep -l "STRING" {} \;
Batch recursive permission change with find and chmod
bash |copy code |?
1 #change directories permissions2 find / -type d -exec chmod 755 {} \;3 4 5 #change files permission
Use find to locate files over a criteria size and format output with awk. Changing value of NF variable you change fields separator
find / -type f -exec chmod 644 {} \;
Search for directories that don’t contain a file we set in options.樂威壯
In our case are .vmx files.
bash |copy code |?
1 find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $NF ": " $5 }'2 bash |copy code |?
1 find /vmfs/volumes/v02tstn02a01/ -type d | while3 read dir; do if [ ! -f $dir/*.vmx ]; then
Find symbolic links to directory
echo $dir; fi; done;