In a Bash shell I can write
some_command $(< some_file)
to pass the contents of some_file to some_command as command-line arguments. How can I best accomplish the same thing on Windows, preferably using built-in commands/syntax?
Edit: To clarify, any form of whitespace in some_file should be treated as argument separators as is the case in my Bash example. In particular, this needs to work even if some_file has multiple lines.
In the Windows Command shell, type is a built in command which displays the contents of a text file. Use the type command to view a text file without modifying it.
To pass command line arguments, we typically define main() with two arguments : first argument is the number of command line arguments and second is list of command-line arguments. The value of argc should be non negative. argv(ARGument Vector) is array of character pointers listing all the arguments.
To list files in Windows using Command Line, first, open up the Command Prompt, then utilize the “dir” command. This will list the folders and files in the current directory.
For example, entering C:\abc.exe /W /F on a command line would run a program called abc.exe and pass two command line arguments to it: /W and /F. The abc.exe program would see those arguments and handle them internally.
set /p ARGS= <some_file
some_command %ARGS%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With