I'm trying to write a script that will loop through all subfolders of a directory to search for a specific file and then copy a new file to those folders that contain that file.
This is what I have so far:
#!/bin/sh dir=/Documents find "$dir" -name Sample.doc -printf "%p\n" | sort -nr | while read -r i; do echo "$i" done
This works to list all the
Sample.doc files and their folders within the
However, I cannot find a way to extract the path from those folders to copy the new file into them.
Any help would be appreciated.