Arguments file
On args.txt, there are long series of arguments for different call of an executable. Each line contain the arguments for a single call of the executable. One line of args.txt looks like
2 1 -A 7 -B true -C 0.0035 -D /path/to/somewhere ....
The line start by 2 1 as the first two arguments to be given to the executable are "unnamed" (do not come with a flag).
First try
I first tried
i=5
./myexec `sed "${i}q;d" args.txt`
it works most of the time. However, for some lines, the arguments are too long and I receive Error: Command Line Too long as I am overpassing getconf ARG_MAX. Note the software does not allow for specifying arguments other than through the command line.
Second try
So I tried
sed "${i}q;d" args.txt | xargs ./myexec
This second try causes the executable to return nothing.
Questions
- Am I doing something wrong with
sed "${i}q;d" args.txt | xargs ./myexec? - Once I fix the second try, will I encounter the same issue (
Command Line Too long) as for the first try? - Could there be a quotation issue which causes
./myexecto consider the long string as a single argument or something similar? - Would you suggest me trying another way of feeding the arguments to
myexec?
FYI
I am on Mac OS X 10.11.3 with Terminal 2.6.1
ARG_MAX, it'll still be too long when you're usingxargs-- xargs will just split it into multiple invocations of your executable, each of them given only a subset of the arguments you want (and thus, neither being correct).ARG_MAXis 262K on OS X. What are you doing that needs more arguments than this?