I have a directory full of text files. My goal is to append text to the beginning and end of all of them. The text that goes at the beginning and end is the same for each file.
Based on code I got from the web, this is the code for appending to the beginning of the file:
echo -e 'var language = {\n$(cat $BASEDIR/Translations/Javascript/*.txt)' > $BASEDIR/Translations/Javascript/*.txt
This is the code for appending to the end of the file. The goal is to add the text };
at the end of each file:
echo "};" >> $BASEDIR/Translations/Javascript/*.txt
The examples I drew from were for acting on individual files. I thought I'd try acting on multiple files using the wildcard, *.txt
.
I might be making other mistakes as well. In any case, how do I append text to the beginning and end of multiple files?
1i
at the beginning of the string passed tosed
is very important here! It's an instruction to "insert before line 1" – Nick F Apr 06 '23 at 17:12