What is the Windows equivalent to the UNIX CAT command?


  1. Posts : 19,383
    Windows 10 Pro x64 ; Xubuntu x64
       #1

    What is the Windows equivalent to the UNIX CAT command?


    G'day,

    Can someone suggest the Windows equivalent of the following UNIX usage of CAT?

    In UNIX:

    Code:
    set i = 1
    cat << EOF > input.txt
    + var_${i} 0 byte Variable 1
    + spc_${i} 0 byte Variable 2
    + arq_${i} 0 integer Variable 3
    EOF
    results in a file called input.txt, that when opened looks like this:

    Code:
    + var_1 0 byte Variable 1
    + spc_1 0 byte Variable 2
    + arq_1 0 integer Variable 3
    I'm trying to achieve the same thing in a .BAT file using the Windows cmd shell, but I'm unsure of the appropriate command and syntax. Can someone offer any pointers?

    Thanks,
    Golden
      My Computer


  2. Posts : 1,030
    Linux Mint / XP / Win7 Home, Pro, Ultimate / Win8.1 / Win10
       #2

    Closest I could remember from DOS is "type" with "+" (haven't used this in 15 years!).

    From Wikipedia:
    The equivalent command in the VMS, CP/M, DOS, OS/2, and Microsoft Windows operating system command shells is type.
    Note: To combine multiple files together in DOS/Windows you can use the "copy /b" command:
    Example:
    copy /b file1.txt + file2.txt file3.txt


    This copies file1.txt and file2.txt in binary mode together in one file, file3.txt.


    Regards,
    GEWB
      My Computer


  3. Posts : 3,371
    W10 Pro desktop, W11 laptop, W11 Pro tablet (all 64-bit)
       #3

    Pretty simple, really.

    Code:
    set i=1
    echo + var_%i% 0 byte Variable 1 > input.txt
    echo + spc_%i% 0 byte Variable 2 >> input.txt
    echo + arq_%i% 0 byte integer Variable 3 >> input.txt
    When outputting to a file from a .BAT file, a single ">" indicates to create a new file while a double ">>" indicates to concatenate to an existing file.
      My Computer


  4. Posts : 1,030
    Linux Mint / XP / Win7 Home, Pro, Ultimate / Win8.1 / Win10
       #4

    +1 ^^^^^
    (I forgot that one!)

    Regards,
    GEWB
      My Computer


  5. Posts : 19,383
    Windows 10 Pro x64 ; Xubuntu x64
    Thread Starter
       #5

    Sorted. Thanks fellas
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:44.
Find Us