Sunday, May 5, 2024
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 26791  / 3 Years ago, sun, july 18, 2021, 5:17:16

What is the command line to run a console application with input argument fed from text file?



text_file:
This is a simple text file with characters and other
symbols including tabs and new lines


The console should get



$./myapp "This is a simple text file with characters and other symbols including tabs and new lines"

More From » command-line

 Answers
3

Use $() (command substitution). With double quotes to pass all the text as a single argument:


./myapp "$(cat text_file)"

Or, using the older form with backticks ` `:


./myapp "`cat text_file`"

You can run without quotes to have the shell split and expand (if wildcards are present) the text:


./myapp $(cat text_file)
./myapp `cat text_file`

[#31099] Monday, July 19, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ionodest

Total Points: 252
Total Questions: 122
Total Answers: 100

Location: Liechtenstein
Member since Tue, Apr 27, 2021
3 Years ago
ionodest questions
Sat, Jan 1, 22, 06:31, 2 Years ago
Wed, May 12, 21, 03:21, 3 Years ago
Tue, Feb 22, 22, 09:46, 2 Years ago
Thu, Jun 30, 22, 12:12, 2 Years ago
;