There are 1000 txt files in a folder. The contents of the files are as follows:
("a1", "b1")
I want to combine all the files into one file. However, I have to separate the contents of each file with commas.
("a1", "b1"), ("a2", "b2")
Then I need to add a fixed text at the beginning and end as below.
START ("a1", "b1"), ("a2", "b2") END
However, as long as the number of files to be added is 100, it should create a new line.
Example:
START ("a1", "b1"), ("a2", "b2") ... END
...
START ("a900", "b900"), ("a901", "b901") ... END
The values I have given in the example are just examples to explain in a simpler way.
I need to write this as a bash script to run on the server.
I was able to do something like the following, but I don't think it's good code. Unfortunately I was unable to create a new line in every 100 files.
echo "START " > all.txt
cat *.txt >> all.txt
sed -i 's/)(/),(/g' all.txt
echo " END" >> all.txt
Frankly, I need your help as it is a very complex code for me.
I am open to your valuable comments and suggestions.
Thank you.