I need to add tags like text of file in thousand of files in a directory and I tried it using cat and outputing it to a stream of file using
for file in *
do
cat ../gau > temp; //gau contain format i need to append in each file
echo $file >>temp;
cat ../gau_ >>temp ;//contains </DOCID>
cat $file >>temp;
cat ../gau1 >> temp; //this contain last sentence </DOC>
cat temp > $file
done
but doing this is very slow. Can someone please tell me a better and more efficient way to do this? Is it possible to do using C? How can we open files in batches and then process them and put back as it can speed up this process since opening and writing file is a bottle neck I suppose.
Is there and premade program (which is efficient and fast) to do this job as we are short on time.