This is my bash script
#!/bin/bash
filenames="root/simulate/*.txt"
for f in "$filenames"; do
#append "#" to all .txt files
sed -i -e 's/^/#/' $filenames
#append content of this bash script to all .txt files
cat "$0" >> "$f"
done
But instead of appending its bash script content to all existing ".txt" files, it creates a new "*.txt" file in the directory and adds the content of the other ".txt" files into it, and then appends the bash script to that new file. Can anybody help? Thank you
sedon$filenamesevery time through the loop, instead of$f?