Friday 25 March 2011

Copying a file to all subdirectories in Linux

You might sometimes need to copy a single file to all the subdirectories and this can be easily achieved with linux terminal by simply using some commands.

Below is how I copied password.txt file to all the subdirectories inside the Moviez directory from terminal.

find /samar/Moviez -type d -exec cp -i /samar/Readme/password.txt {} \;

Isn't it simple? And it will surely come handy sometimes. Have fun. :)