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)

  • 1
    None of these suggestions can accept a redirect of STDIN.
    – will
    Commented Apr 19, 2016 at 3:11
  • 5
    Powershell: cat file.txt Commented Oct 5, 2016 at 18:12
  • Cross-duplicate: stackoverflow.com/q/60244/11683
    – GSerg
    Commented Jul 8, 2019 at 20:53
  • The answers provided are all commands available in different shells. Is there an executable which sends its arguments to stdout?
    – phreed
    Commented Apr 14, 2020 at 22:02
  • @phreed If you are working on cmd.exe, there is the echo built-in. For PowerShell there is the Write-Output cmdlet (which also happens to be aliased by echo). Commented Jan 4, 2021 at 21:14

3 Answers 3



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
  • 24
    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! Commented Jun 10, 2012 at 16:33
  • 55
    Cat doesn't really seem much better. Commented Jun 10, 2012 at 16:51
  • 12
    @DavidBoike Although cat is from con_cat_enate AFAIR.
    – Mark Hurd
    Commented Jun 10, 2012 at 17:55
  • 27
    @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?? Commented Jun 10, 2012 at 18:21
  • 25
    @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
    Commented Jun 10, 2012 at 19:50

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
    Commented Jun 10, 2012 at 9:12
  • 1
    Bob, except if switches and options are involved.
    – Joey
    Commented Jun 10, 2012 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
    Commented Jun 10, 2012 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
    Commented Jun 10, 2012 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
    Commented Jun 14, 2012 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.

  • 12
    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
    Commented May 9, 2016 at 14:22
  • 2
    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
    Commented Jun 16, 2017 at 1:15
  • you can also use type command type *.txt > file.merge
    – Riz
    Commented Oct 27, 2017 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .