Timeline for Write variable containing large text with \n to a file with common shell interpreters. How do you do it?
Current License: CC BY-SA 3.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 5, 2014 at 11:52 | comment | added | mikeserv | @PierfrancescoPierQRAiello Ok. Then the heredocument will work. It's a good solution, though I still don't understand how you get it in the first place. Oh well, I'll let it be... | |
Aug 5, 2014 at 8:37 | comment | added | Pier A |
Thanks for the hints @mikeserv . The point is, let's say, that i cannot change the code that produce $a for some "high order call". Then i'm stuck with this problem. I'm just allowed to print the value of the variable to a file.
|
|
Aug 5, 2014 at 6:38 | comment | added | mikeserv |
@PierfrancescoPierQRAiello - also, nearly everything @peterph told you before was incorrect. If it is an ARG_MAX problem then it can only be because you're not using the shell's builtin utilities. You may fare much better with busybox echo "$a" for instance.
|
|
Aug 5, 2014 at 6:36 | comment | added | mikeserv |
@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.
|
|
Aug 5, 2014 at 6:24 | comment | added | Pier A | 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. | |
Aug 5, 2014 at 1:23 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 1 character in body
|
Aug 5, 2014 at 1:11 | history | edited | mikeserv | CC BY-SA 3.0 |
added 115 characters in body
|
Aug 5, 2014 at 1:08 | comment | added | mikeserv | @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. | |
Aug 5, 2014 at 1:03 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 48 characters in body
|
Aug 4, 2014 at 23:40 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 39 characters in body
|
Aug 4, 2014 at 23:27 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 39 characters in body
|
Aug 4, 2014 at 22:39 | comment | added | mikeserv | @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. | |
Aug 4, 2014 at 22:36 | history | edited | mikeserv | CC BY-SA 3.0 |
added 428 characters in body
|
Aug 4, 2014 at 22:33 | comment | added | peterph | not really answering the question - the problem is passing large amounts of data on command line. | |
Aug 4, 2014 at 22:16 | review | Low quality posts | |||
Aug 4, 2014 at 22:32 | |||||
Aug 4, 2014 at 22:08 | history | edited | mikeserv | CC BY-SA 3.0 |
deleted 5 characters in body
|
Aug 4, 2014 at 21:57 | history | answered | mikeserv | CC BY-SA 3.0 |