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)
53 Answers
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 16 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.txtand you can control (using -Encoding parameter) the file encoding (which allows transcoding by using different encoding for the read and write).
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.