I want to do exactly what unix "cat" does, but on my PC. Is there a simple equivalent command for the Windows command line?

Specifically I want to create a file from all the files of a given type in a folder

In Unix:

cat *fna >all_fna_files.fna

(which joins all the ".fna" text files into one big text file)

  • None of these suggestions can accept a redirect of STDIN. – will Apr 19 '16 at 3:11
  • 2
    Powershell: cat file.txt – Kolob Canyon Oct 5 '16 at 18:12


It works across command.com, cmd, and PowerShell (though in the latter it's an alias for Get-Content, so is cat, so you could use either). From the Wikipedia article (emphasis mine):

In computing, type is a command in various VMS. AmigaDOS, CP/M, DOS, OS/2 and Microsoft Windows command line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to display the contents of specified files. It is analogous to the Unix cat command.

C:\>echo hi > a.txt
C:\>echo bye > b.txt
C:\>type a.txt b.txt > c.txt
C:\>type c.txt
  • 5
    Good informative answer, so +1. Wish that I could give Microsoft a -1 though for the utterly ambiguous command name. type filename makes me think that the command should return the type of file, not the contents of the file! – PenguinCoder Jun 10 '12 at 16:33
  • 25
    Cat doesn't really seem much better. – David Boike Jun 10 '12 at 16:51
  • 7
    @davidboike It is much better because it actually means and stands for what it does: The cat program is a standard Unix utility that concatenates and lists files. The name is an abbreviation of catenate, a synonym of concatenate. Wikipedia Article Can you say the same for the MS-DOS type command?? – PenguinCoder Jun 10 '12 at 18:21
  • 10
    @PenguinCoder Except type doesn't concatenate files; it just types their contents to the screen. Its the piping in the example that is actually combining the files, not the type command. – Andy Jun 10 '12 at 19:50
  • 5
    MS-DOS likely inherited TYPE from CP/M by way of QDOS. The TYPE command displays the content of the ASCII source file ufn on the currently logged disk at the console device. – a CVn Jun 11 '12 at 11:07

From the command shell:

copy a.txt + b.txt + c.txt output.txt

(But that follows the command shells use of control-Z as an end of file marker, so not suitable in some cases).

In PowerShell:

get-content a.txt,b.txt,c.txt | out-file output.txt

and you can control (using -Encoding parameter) the file encoding (which allows transcoding by using different encoding for the read and write).

  • 8
    PowerShell aliases cat to Get-Content too. It's designed to accept many basic Linux commands without much, if any, modification. – Bob Jun 10 '12 at 9:12
  • 1
    Bob, except if switches and options are involved. – Joey Jun 10 '12 at 16:25
  • @Richard: Copy /b a + b + c output.txt doesn't check for on Ctrl-Z. Both variants will copy the entire file if there is NO ctrl-Z in the file. – Tonny Jun 10 '12 at 18:28
  • 2
    Note that you can include wildcards too, the way wildcards work in windows means you won't be messed up by the expansion list not containing a +, so copy [/b] *.fna all_fna_files.fna.. – Random832 Jun 10 '12 at 22:24
  • if I recall from an old test I once did, using COPY with /B to concatenate, will ignore CTRL-Z/EOF markers, and will do the concatenation properly! but judging by copy /? you may need to do a lot of /B like it seems maybe after copy, after each src file and after the dest file.. strange. – barlop Jun 14 '12 at 6:38

I have just used the cat command in DOS (Windows 7 Pro) in the following manner and successfully merged 3 files (log1.txt, log2.txt, log3.txt) into a single file:

cat log*.txt >> myBigLogFile.txt 

Note: cat log*.txt > myBigLogFile2.txt also provide the same result, but it'll override the previous file.

  • 3
    maybe you have GNU for Windows, or Cygwin in your path, or are using powershell because cat does not exist on a clean Windows 7 system. DOS is no longer a thing, but most people would use it to refer to cmd.exe. – Shanteva May 9 '16 at 14:22
  • 1
    Windows CMD and MS-DOS are not the same thing. There's no cat command in both cmd and DOS, only cat alias in powershell – phuclv Jun 16 '17 at 1:15
  • you can also use type command type *.txt > file.merge – Riz Oct 27 '17 at 15:00

protected by Nifle Mar 20 '15 at 17:16

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.