Saturday, July 12, 2008

Find command to execute same command to multiple directories

If you want to apply a command to a directory recursively, use find.
Here's how:

find . -exec echo {} \;

The above code will execute the command "echo" on every filename in the current directory, and all subdirectories recursively.

The '.' means 'current directory' (you could put any directory name instead of it), 'echo' is a command you want to execute.
'{}' is like a variable that represents the filename for each file.

find /mnt/users/ajaved -exec echo {} \;

Sphere: Related Content

0 comments: