1

Struggling with outputting huge text (around 500 KB) to a file on linux. Text contains spaces, special characters and other.... Getting error /bin/sh : argument list too long

#!/bin/bash
txt="---huge text separated by line and containing special characters---"
echo $txt

or

#!/bin/bash
txt="---huge text separated by line and containing special characters---"
echo $txt >> filename.txt

1 Answers1

1

a workaround to avoid escaping " and ' , keep your output readable when viewing script is this : cat >output <<textmarker -construct Example:

#!/bin/bash

cat >filename.txt <<EOT
Your output-text starts here
Every new line or tab  will be on the output too
  "text0" 'text1'  echo "Hello" 
  #Any other even huge text   //
\n But Dollarsign and backslash have to be escaped 
For example \$ and \\
your output-text ends with this marker, which had to be on a newline without whitespace
EOT
  • Use <<\EOF if you don't want to have to escape every $, ``` and backslash. – Stéphane Chazelas Mar 13 '18 at 16:12
  • I removed special characters, newlines, white spaces and other characters. Now I am just having alphanumeric characters of total selection greater than 131052.. ....Still getting error /bin/sh : argument list too long [code] #!/bin/bash txt="---huge text with total characters length 131053---" [/code] – Rohit Borse Mar 14 '18 at 07:21
  • Ok, I figured out why this is happening. Size of command buffer in my system is 131072. When total text on input console is exceeding this limit then its giving argument list too long error. How I can increase this command buffer size? – Rohit Borse Mar 14 '18 at 07:36