What is the Windows equivalent of the Unix command cat?
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)
type
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
hi
bye
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).