Regarding your question about the Linux terminal command line. The answer is: It can handle much larger strings, which are pretty much dependant on how much free RAM you have. Eg. From the command line, I just ran
printf '%s' with a 20,000,000 byte string; it had no problems. I also ran it through
sed.exe (in a Linux wine environment); this worked fine, too... Whatever the command line limit may be, it also depends on what the program you are feeding such large strings can handle as their command input maximum size.
But it is an unusual/strange situation in which you would want to pass such large strings to a program, because you will at some point reach a maximum.
sed and such large strings, you can do either of two things:
Write your data to a file and use:
sed "s@ab/cd@AB_CD@" my_data_file
pipe (|) the output of a command to sed's standard input:
my_data_app | sed "s@ab/cd@AB_CD@"
Note that sed itself may have some line length limit, but from memory, GNU sed's limit is quite high.
Also, instead of the default
/, I have used
@, but you can use pretty much anything you like.