How to copy one file over all others? [closed]











up vote
-2
down vote

favorite












Okay, so I know this is possible because I found a thread in the past explaining how to do such but I just cannot find it again for the life of me. How do you copy one file in a folder over all the other files present in said folder (thusly overwriting), with just a simple, one liner bash command?



That's all I wish to know, thank you :)










share|improve this question













closed as off-topic by jww, Pearly Spencer, dur, Machavity, Makyen Nov 9 at 23:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – jww, Pearly Spencer, dur, Machavity, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.













  • You mean if there are 10 files a0.txt to a9.txt, you want to be able to make 10 copies of a0.txt?
    – icedwater
    Nov 9 at 15:21










  • I wish to copy english.php over all the other language files that are present in the directory all at once, such as dutch.php, french.php, etc.
    – Phobos D'thorga
    Nov 9 at 15:24















up vote
-2
down vote

favorite












Okay, so I know this is possible because I found a thread in the past explaining how to do such but I just cannot find it again for the life of me. How do you copy one file in a folder over all the other files present in said folder (thusly overwriting), with just a simple, one liner bash command?



That's all I wish to know, thank you :)










share|improve this question













closed as off-topic by jww, Pearly Spencer, dur, Machavity, Makyen Nov 9 at 23:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – jww, Pearly Spencer, dur, Machavity, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.













  • You mean if there are 10 files a0.txt to a9.txt, you want to be able to make 10 copies of a0.txt?
    – icedwater
    Nov 9 at 15:21










  • I wish to copy english.php over all the other language files that are present in the directory all at once, such as dutch.php, french.php, etc.
    – Phobos D'thorga
    Nov 9 at 15:24













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











Okay, so I know this is possible because I found a thread in the past explaining how to do such but I just cannot find it again for the life of me. How do you copy one file in a folder over all the other files present in said folder (thusly overwriting), with just a simple, one liner bash command?



That's all I wish to know, thank you :)










share|improve this question













Okay, so I know this is possible because I found a thread in the past explaining how to do such but I just cannot find it again for the life of me. How do you copy one file in a folder over all the other files present in said folder (thusly overwriting), with just a simple, one liner bash command?



That's all I wish to know, thank you :)







linux bash terminal copy cp






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 15:19









Phobos D'thorga

171214




171214




closed as off-topic by jww, Pearly Spencer, dur, Machavity, Makyen Nov 9 at 23:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – jww, Pearly Spencer, dur, Machavity, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by jww, Pearly Spencer, dur, Machavity, Makyen Nov 9 at 23:35


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – jww, Pearly Spencer, dur, Machavity, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.












  • You mean if there are 10 files a0.txt to a9.txt, you want to be able to make 10 copies of a0.txt?
    – icedwater
    Nov 9 at 15:21










  • I wish to copy english.php over all the other language files that are present in the directory all at once, such as dutch.php, french.php, etc.
    – Phobos D'thorga
    Nov 9 at 15:24


















  • You mean if there are 10 files a0.txt to a9.txt, you want to be able to make 10 copies of a0.txt?
    – icedwater
    Nov 9 at 15:21










  • I wish to copy english.php over all the other language files that are present in the directory all at once, such as dutch.php, french.php, etc.
    – Phobos D'thorga
    Nov 9 at 15:24
















You mean if there are 10 files a0.txt to a9.txt, you want to be able to make 10 copies of a0.txt?
– icedwater
Nov 9 at 15:21




You mean if there are 10 files a0.txt to a9.txt, you want to be able to make 10 copies of a0.txt?
– icedwater
Nov 9 at 15:21












I wish to copy english.php over all the other language files that are present in the directory all at once, such as dutch.php, french.php, etc.
– Phobos D'thorga
Nov 9 at 15:24




I wish to copy english.php over all the other language files that are present in the directory all at once, such as dutch.php, french.php, etc.
– Phobos D'thorga
Nov 9 at 15:24












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Maybe not the most efficient, but the following will work :



find . -not -name 'english.php' -exec cp 'english.php' '{}' ;


It runs cp 'english.php' '<file>' for every file of the current directory that isn't english.php






share|improve this answer





















  • Excellent, thank you! I find this quite elegant ^ ^
    – Phobos D'thorga
    Nov 9 at 15:35










  • The problem is that it calls cp for every file, which isn't very efficient. I wouldn't be surprised if there was rsync invocation that could do it all in one shot.
    – Aaron
    Nov 9 at 15:54










  • There's only 26 files in total, and they're only a few hundred kilobytes each. It does the job so I'm happy :)
    – Phobos D'thorga
    Nov 9 at 15:56


















up vote
-1
down vote













I guess something like



cp english.php copyme.txt && for file in *.php; do cat copyme.txt > $file; done && rm copyme.txt


Would replace the contents of all .php files with the contents of english.php.



I don't know if



cat english.php > *.php


works, there should be some way to force a clobber that I have forgotten for now.






share|improve this answer

















  • 1




    cat english.php > *.php wouldn't work, it would raise an "ambiguous redirection" error.
    – Aaron
    Nov 20 at 16:56


















2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Maybe not the most efficient, but the following will work :



find . -not -name 'english.php' -exec cp 'english.php' '{}' ;


It runs cp 'english.php' '<file>' for every file of the current directory that isn't english.php






share|improve this answer





















  • Excellent, thank you! I find this quite elegant ^ ^
    – Phobos D'thorga
    Nov 9 at 15:35










  • The problem is that it calls cp for every file, which isn't very efficient. I wouldn't be surprised if there was rsync invocation that could do it all in one shot.
    – Aaron
    Nov 9 at 15:54










  • There's only 26 files in total, and they're only a few hundred kilobytes each. It does the job so I'm happy :)
    – Phobos D'thorga
    Nov 9 at 15:56















up vote
1
down vote



accepted










Maybe not the most efficient, but the following will work :



find . -not -name 'english.php' -exec cp 'english.php' '{}' ;


It runs cp 'english.php' '<file>' for every file of the current directory that isn't english.php






share|improve this answer





















  • Excellent, thank you! I find this quite elegant ^ ^
    – Phobos D'thorga
    Nov 9 at 15:35










  • The problem is that it calls cp for every file, which isn't very efficient. I wouldn't be surprised if there was rsync invocation that could do it all in one shot.
    – Aaron
    Nov 9 at 15:54










  • There's only 26 files in total, and they're only a few hundred kilobytes each. It does the job so I'm happy :)
    – Phobos D'thorga
    Nov 9 at 15:56













up vote
1
down vote



accepted







up vote
1
down vote



accepted






Maybe not the most efficient, but the following will work :



find . -not -name 'english.php' -exec cp 'english.php' '{}' ;


It runs cp 'english.php' '<file>' for every file of the current directory that isn't english.php






share|improve this answer












Maybe not the most efficient, but the following will work :



find . -not -name 'english.php' -exec cp 'english.php' '{}' ;


It runs cp 'english.php' '<file>' for every file of the current directory that isn't english.php







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 15:27









Aaron

14.6k11636




14.6k11636












  • Excellent, thank you! I find this quite elegant ^ ^
    – Phobos D'thorga
    Nov 9 at 15:35










  • The problem is that it calls cp for every file, which isn't very efficient. I wouldn't be surprised if there was rsync invocation that could do it all in one shot.
    – Aaron
    Nov 9 at 15:54










  • There's only 26 files in total, and they're only a few hundred kilobytes each. It does the job so I'm happy :)
    – Phobos D'thorga
    Nov 9 at 15:56


















  • Excellent, thank you! I find this quite elegant ^ ^
    – Phobos D'thorga
    Nov 9 at 15:35










  • The problem is that it calls cp for every file, which isn't very efficient. I wouldn't be surprised if there was rsync invocation that could do it all in one shot.
    – Aaron
    Nov 9 at 15:54










  • There's only 26 files in total, and they're only a few hundred kilobytes each. It does the job so I'm happy :)
    – Phobos D'thorga
    Nov 9 at 15:56
















Excellent, thank you! I find this quite elegant ^ ^
– Phobos D'thorga
Nov 9 at 15:35




Excellent, thank you! I find this quite elegant ^ ^
– Phobos D'thorga
Nov 9 at 15:35












The problem is that it calls cp for every file, which isn't very efficient. I wouldn't be surprised if there was rsync invocation that could do it all in one shot.
– Aaron
Nov 9 at 15:54




The problem is that it calls cp for every file, which isn't very efficient. I wouldn't be surprised if there was rsync invocation that could do it all in one shot.
– Aaron
Nov 9 at 15:54












There's only 26 files in total, and they're only a few hundred kilobytes each. It does the job so I'm happy :)
– Phobos D'thorga
Nov 9 at 15:56




There's only 26 files in total, and they're only a few hundred kilobytes each. It does the job so I'm happy :)
– Phobos D'thorga
Nov 9 at 15:56












up vote
-1
down vote













I guess something like



cp english.php copyme.txt && for file in *.php; do cat copyme.txt > $file; done && rm copyme.txt


Would replace the contents of all .php files with the contents of english.php.



I don't know if



cat english.php > *.php


works, there should be some way to force a clobber that I have forgotten for now.






share|improve this answer

















  • 1




    cat english.php > *.php wouldn't work, it would raise an "ambiguous redirection" error.
    – Aaron
    Nov 20 at 16:56















up vote
-1
down vote













I guess something like



cp english.php copyme.txt && for file in *.php; do cat copyme.txt > $file; done && rm copyme.txt


Would replace the contents of all .php files with the contents of english.php.



I don't know if



cat english.php > *.php


works, there should be some way to force a clobber that I have forgotten for now.






share|improve this answer

















  • 1




    cat english.php > *.php wouldn't work, it would raise an "ambiguous redirection" error.
    – Aaron
    Nov 20 at 16:56













up vote
-1
down vote










up vote
-1
down vote









I guess something like



cp english.php copyme.txt && for file in *.php; do cat copyme.txt > $file; done && rm copyme.txt


Would replace the contents of all .php files with the contents of english.php.



I don't know if



cat english.php > *.php


works, there should be some way to force a clobber that I have forgotten for now.






share|improve this answer












I guess something like



cp english.php copyme.txt && for file in *.php; do cat copyme.txt > $file; done && rm copyme.txt


Would replace the contents of all .php files with the contents of english.php.



I don't know if



cat english.php > *.php


works, there should be some way to force a clobber that I have forgotten for now.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 15:30









icedwater

3,38532342




3,38532342








  • 1




    cat english.php > *.php wouldn't work, it would raise an "ambiguous redirection" error.
    – Aaron
    Nov 20 at 16:56














  • 1




    cat english.php > *.php wouldn't work, it would raise an "ambiguous redirection" error.
    – Aaron
    Nov 20 at 16:56








1




1




cat english.php > *.php wouldn't work, it would raise an "ambiguous redirection" error.
– Aaron
Nov 20 at 16:56




cat english.php > *.php wouldn't work, it would raise an "ambiguous redirection" error.
– Aaron
Nov 20 at 16:56



Popular posts from this blog

Schultheiß

Liste der Kulturdenkmale in Wilsdruff

Android Play Services Check