hi,
i need to merge 2 lakh text files .....
can somebody please help me with a script/program for it...
hi,
i need to merge 2 lakh text files .....
can somebody please help me with a script/program for it...
hi gurus,
i have 2.2 lakh small files in a folder....
i need to merge all those files into one and use it....
can you please help me with a solution?
Your question is a bit vague.
If you just one to append one file to another, you can use cat or tee.
cat file1 file2 >file3
# or
cat file2 >>file1
# or
tee -a file1 file2
you are correct ...
but i have 2 lakh such files....and the file names are not in any particular order....
You could do something like this
for files in a b c d e f g h i j k l m n o p q r s t u v w x y z
do
cat "${files}"* >> /tmp/bigfile.txt
done
What do you mean by "lakh"??
Try this:
find . -type f -exec tee -a ../outfile "{}" \;
For the uninitiated, lakh is a unit in the Indian numbering system.
One lakh would translate to a hundred thousand
1 lakh = 100,000
This will append "bigfile.txt" to the output contained in bigfile.txt. To avoid this, put bigfile.txt in a different directory, like I did with my find example.
Use the below code :
$ cat merge.sh
for file in $@
do
cat $file>>merge.txt
done
Run the script merge.sh as below:
$merge.sh *
This will merge all the files in the directory to one file