I need to copy a file (or actually a symlink) to every subdirectory on a path. I know that cp -s will do the copy I want, but how can I get it to go into every subdirectory? I''ve tried different iterations of ls to get a listing of directories only (recursively) without success. TIA Mike
Mike Kercher wrote:> I need to copy a file (or actually a symlink) to every subdirectory on a > path. > > I know that cp -s will do the copy I want, but how can I get it to go into > every subdirectory? I''ve tried different iterations of ls to get a listing > of directories only (recursively) without success. > > TIA > > Mikefind <directory> -type d -exec echo cp <file> "{}" \; Remove the echo to do it for real. -Mike
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mike Kercher wrote: | I need to copy a file (or actually a symlink) to every subdirectory on a | path. | | I know that cp -s will do the copy I want, but how can I get it to go into | every subdirectory? I''ve tried different iterations of ls to get a listing | of directories only (recursively) without success. find . -type d -exec ln -s /path/to/orignal/file "{}"/. \; this includes the current directory -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFCIkUqCRFXD+VcGBkRAuJbAJ9qqoSajbL6zh+1kzoneUBo2fAGhQCfUBlq KSugmxe43LrDSXgGuRjZF0Q=1JbK -----END PGP SIGNATURE-----
Michael Best wrote:> Mike Kercher wrote: >> I need to copy a file (or actually a symlink) to every subdirectory >> on a path. >> >> I know that cp -s will do the copy I want, but how can I get it to go >> into every subdirectory? I''ve tried different iterations of ls to >> get a listing of directories only (recursively) without success. >> >> TIA >> >> Mike > > find <directory> -type d -exec echo cp <file> "{}" \; > > Remove the echo to do it for real. > > -MikeThanks Mike and Donovan. That worked like a champ! I didn''t even think of using find! Mike