Home‎ > ‎Basics‎ > ‎

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

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