I was looking for a Windows CMD equivalent to something like
var=`ls`
in Unix. Is there a way to do so without having to iterate using for /f?
You can do it with PowerShell (and script it in a .ps1).
PS C:\> $myVar = & dir | format-table -hidetableheaders -property name
PS C:\> echo $myVar
Program Files
Program Files (x86)
Users
Windows
lsequivalent command in dos isdirCD > tmpFileSET /p myvar= < tmpFile