Home‎ > ‎Basics‎ > ‎

Write content of a file to multiple files using cat in bash


Canagon.com - Website for $499, beautiful premade designs, high-performance hosting on all continents, dedicated support team. Learn more >

I use this command to rewrite all php files in directory with specific content. Write content into the file, ex. using nano:

$ sudo nano content.txt

Following command will output content of the content.txt and rewrite all php files in current directory:

$sudo for filename in *.php; do cat content.txt > $filename; done