exec on find

?>

exec on find

OBJECT

Some exemples if you want to use the results of a find command thru a pipe

DESCRIPTION

You want to rename some files in a tree (all .html file in .htm for instance)

			find . -type f -name "*.html' \
			| sed -n -e 's/.*/mv & &/' -e 's/.html$/.htm/' -e p \
			| sh
		

DESCRIPTION

You want to rename some files in a tree, changing the case

			find . -type f  \
			| while read f
			do
				bname=${f##*/}
				dname=${f%/*}
				lname=$(echo $bname | tr '[A-Z]' '[a-z]')
				mv $f $dname/$lname
			done
		

DESCRIPTION

The same as above but, for some version of bash, you will need :

			find . -type f  \
			| xargs -l1 basch -c '
				bname=${1##*/}
				dname=${1%/*}
				lname=$(echo $1 | tr '[A-Z]' '[a-z]')
				mv $f $dname/$lname
				' --
		

DESCRIPTION

You want to delete files in a tree (all file ending with '.old') answering with 'y' to validate

			find . -type f -name "*.old' -ok rm {} \;
		

DESCRIPTION

The same as above, without validation

			find . -type f -name "*.old' -exec rm {} \;
		

DESCRIPTION

The same as above but more performant because it dosn't create 2 processes by line, but try to fullfill a command line before launching it.

			find . -type f -name "*.old' | xargs rm
		

DESCRIPTION

You want to copy a tree.

			find . | cpio -pdmuv /other_place