Comment from start of file to a pattern matched line using sed
As a one-liner to demonstrate the concept :
echo -e 'a\nb\nc\nPATTERN\nd\ne\nf' | sed '0,/PATTERN/ s/^/#/'
You just have to adapt to your context :
- as for the 'PATTERN'
- I assumed '#' as the commenting character
- and regarding how you can apply this to all your files. If they all are 'fileXXX.txt', you can run :
sed -i '0,/PATTERN/ s/^/#/' file*txt