Have you ever wanted to merge a bunch of text files together into one large one? For example, if you use a tool to go grab a bunch of show command results and output it to a text file per device, it's handy if you can have the operating system merge all that together for you. Many of you have likely done this at one point or another, but I figured it was worth capturing here to share the syntax.
So, if you are in a Windows command prompt, you can use the type command to output the contents of a file.
C:\>type text1.txt This is a test.
Then you can use the type command plus the double arrows to merge a bunch of files:
C:\>type *.txt >> merge.txt text1.txt text2.txt text3.txt text4.txt
This leaves you with all the original files plus a new one called merge.txt. Piece of cake.
If you are in Linux, you can similarly redirect console output and merge files using the cat command:
cat *.txt >> merged.txt
That's it for this post. If you have a cool command line way of working with files, feel free to share in the comments below!