boofulls
asked on
cp the same file
if i have 10 dirs in a dir
number 1 to 10
how can i copy 1/text.txt into all the other dirs
so that i then have
1/text.txt
2/text.txt
3/text.txt etc......
number 1 to 10
how can i copy 1/text.txt into all the other dirs
so that i then have
1/text.txt
2/text.txt
3/text.txt etc......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ls -p1 | fgrep / | xargs -n1 -i cp 1/text.txt {}
The 'ls -p1 | fgrep /' part gets a list of all directories.
The ' xargs -n1 -i cp 1/text.txt {}' part copies the specified file to all those directories.
You should ignore the error reported when this command tries to copy 1/text.txt to itself.
The 'ls -p1 | fgrep /' part gets a list of all directories.
The ' xargs -n1 -i cp 1/text.txt {}' part copies the specified file to all those directories.
You should ignore the error reported when this command tries to copy 1/text.txt to itself.
do
cp 1/text.txt $dir
done