I have a series of folders containing three files that I want to concatenate as part of a script.
The three files are named file.html1 file.html2 file.html3. I want to concatenate them into file.html
I'm using this loop:
find . -name "file.html" -print0 | while IFS= read -r -d '' n; do perl -i.bak -0pe 's/<\/h2>\n(.*?\n)*/<\/h2>\n/' "$n" #extract 1st part of file.html and create .bak perl -i -0pe 's/(.*\n)*.*?<\/h2>\n//' "$n.bak" #extract 2nd part of file.html rename 's/\.html/\.html1/' $n rename 's/\.bak/3/' $n.bak cat $n1 $n2 $n3 >> $n done
This script splits the original file.html into file.html1 and file.html3. file.html2 was produced earlier in the script.
The problem is with the cat command. How can I concatenate them in this case and then delete the three fragments? The language is not important.