I'm trying to enter a command with VERY big argument (1 MB in size), but it says "Argument list too long." How can I enter that argument?
OS: Linux Ubuntu
There is no way to pass an argument between executables if it is larger than the kernel's
If you have a list of arguments which is too long, splitting it up into smaller pieces can be done e.g. with
xargs. This runs the command as many times as necessary, supplying as many arguments as will fit.
The syntax is
xargs command <file. If you omit
command, it displays its arguments, like
As a demo,
xargs -n 4 </etc/motd
will print the first four tokens on one line (first invocation), the next four through another, etc. (The
-n argument sets a maximum number of arguments, so this doesn't use the
ARG_MAX limit at all.)
If the command you want to run has side effects which are undesirable, this might not work. For example, if the
command will overwrite any previously existing
./a.out file, you will obviously be left with the results from just the last run after it finishes.
If you can configure or modify
command so it reads a file, or standard input, instead of a command-line argument, that will work around the restriction. A file or stream can be much larger than
ARG_MAX, and often is.