Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use file contents as command-line arguments Windows

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.

like image 384
Matt Avatar asked Jun 10 '19 17:06

Matt


People also ask

How do I display the contents of a file in Windows command prompt?

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.

How do you pass values into command line arguments?

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.

How do I list the contents of a file in Windows Terminal?

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.

How do I pass a command line argument in Windows?

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.


1 Answers

set /p ARGS= <some_file
some_command %ARGS%
like image 95
Seva Alekseyev Avatar answered Nov 15 '22 04:11

Seva Alekseyev