Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.



Windows 7: What is the Windows equivalent to the UNIX CAT command?

15 Mar 2012   #1

Microsoft Community Contributor Award Recipient

Windows 7 Ult. x64 Windows 8.1 x64 Ubuntu 12.04 LTS Tri-Boot
 
 
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 System SpecsSystem Spec
.

15 Mar 2012   #2

32bit: XP, Win7 H.P. / 64bit: 2008R2, Win7 Pro, Ultimate / Several flavors of Linux
 
 

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 System SpecsSystem Spec
15 Mar 2012   #3

Win 7 Ultimate (64-bit), Win 8 (64-bit)
 
 

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 System SpecsSystem Spec
.


15 Mar 2012   #4

32bit: XP, Win7 H.P. / 64bit: 2008R2, Win7 Pro, Ultimate / Several flavors of Linux
 
 

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

Regards,
GEWB
My System SpecsSystem Spec
16 Mar 2012   #5

Microsoft Community Contributor Award Recipient

Windows 7 Ult. x64 Windows 8.1 x64 Ubuntu 12.04 LTS Tri-Boot
 
 

Sorted. Thanks fellas
My System SpecsSystem Spec
Reply

 What is the Windows equivalent to the UNIX CAT command?





Thread Tools



Similar help and support threads for2: What is the Windows equivalent to the UNIX CAT command?
Thread Forum
Linux/UNIX Commands in Windows CLI? Software
Windows equivalent for the Linux terminal command iwconfig Network & Sharing
What has Linux and UNIX to do with D-Link DNS-320 and a Windows 7 comp Network & Sharing
Windows 7 *.* Equivalent General Discussion
SAMBA share windows 7 and HP Unix Network & Sharing
Windows 7 UNIX Free Resources Available for Download. News
Kerberos Authentication to UNIX from Windows 7 OS System Security

Our Sites

Site Links

About Us

Find 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 03:14 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33