Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • not really answering the question - the problem is passing large amounts of data on command line. Commented Aug 4, 2014 at 22:33
  • 1
    @peterph : Here's the question I read. How do you write such a variable to a text file, possibly using only simple commands and not sed/awk/perl/other powerful interpreter[?] The answer I propose lies in generating and writing the variable's value at once, using only simple commands... etc. Commented Aug 4, 2014 at 22:39
  • @PierfrancescoPierQRAiello - please do this instead of the other thing I used to have here just in case you're doing that one. It is essentially the same, byut far simpler. Just in case you're doing the other thing, that is. Commented Aug 5, 2014 at 1:08
  • thanks Mikeserv, but the variable is given. I cannot improve the generation of it (else peterph would have already replied). You get this huge stuff and you need to write it to a file. Commented Aug 5, 2014 at 6:24
  • @PierfrancescoPierQRAiello - then you need to use the heredoc like the Michael Homer suggests. Still, I cannot understand how it can be given - it has to get into the shell somehow. Either it is generated by iterating as you demonstrate and can be replaced like I demo above, or it is sourced from a file, in which case you do busybox ash ./file >oufile. You shouldn't ever have to store information of that size in a single shell variable ever. You would probably have better luck with the argument array as well, like set -- "$@" "$a" once every iteration - to avoid a single long string. Commented Aug 5, 2014 at 6:36