Is it possible to copy a single file to multiple directories using the cp command ?
I tried the following , which did not work:
cp file1 /foo/ /bar
Suppose you want to copy fileName.txt
to all sub-directories within present working directory.
Get all sub-directories names through ls
and save them to some temporary file say, allFolders.txt
ls > allFolders.txt
Print the list and pass it to command xargs
.
cat allFolders.txt | xargs -n 1 cp fileName.txt