How do I use the lines of a file as arguments of a command?

Yoo :

Say, I have a file foo.txt specifying N arguments

arg1
arg2
...
argN

which I need to pass to the command my_command

How do I use the lines of a file as arguments of a command?

glenn jackman :

If your shell is bash (amongst others), a shortcut for $(cat afile) is $(< afile), so you'd write:

mycommand "$(< file.txt)"

Documented in the bash man page in the 'Command Substitution' section.

Alterately, have your command read from stdin, so: mycommand < file.txt

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I use command arguments with Cmnd_Alias in sudoers?

How do I use filenames that start with a dash "-" as command arguments?

How do I use a default array if no command line arguments are given?

How do I use file contents as arguments in crontab

How do I use the windows command prompt to copy a file

How do I use the pipe command to display attributes in a file?

How do I use file names in a sed command?

How do I use the xargs command to read the content of a file?

How do I pass arguments to react-scripts start command and use them in react?

How do I use new line characters (\n) with command line arguments in node?

How do I execute a command merging environment variables and variable arguments from a file with xargs?

How do I execute a command merging environment variables and variable arguments from a file with xargs?

How do I execute a command merging environment variables and variable arguments from a file with xargs?

How do I use a grep command to display lines that only have a space character?

How do I delete lines matching multiple pattern in text file using bash command?

How do I get some lines from TXT file with CMD (Only Windows Command Line)

How do I use awk to properly extract lines from a file using numbers from another file?

How do I fetch lines in a log file

How do I comment lines in .plist file?

how do I open file to print lines?

How I do invoke a PowerShell Start-Process command with arguments that require quoting from a Command Prompt / batch file?

How do I count lines and do simple division on the command line?

How to use file contents as command-line arguments?

How do I use grep to search for lines containing all words in a list with no specific order in a text file?

How to use sed command to delete lines without backup file?

How can I use command line arguments in Angularjs Protractor?

How can I use spaces in systemd command line arguments?

How can I use getopt with command line arguments in Swift 3?

How can i use asterisk(*) in command line arguments in groovy?