Reputation
22,978
Next tag badge:
912/400 score
77/80 answers
Badges
3 53 83
Newest
 Enlightened
Impact
~1.0m people reached

Dec
11
comment Storing longer text output in memory in shell variables vs Writing to disk
@mikeserv I'm sorry, that is not the case. You can see this yourself: foo='not in the environment'; envfoo='in the environment'; export envfoo; env | grep foo= and see what you can get. Only the exported variable is shown. I've looked at your links and nothing in them contradicts this.
Dec
11
comment Storing longer text output in memory in shell variables vs Writing to disk
@mikeserv A single 8MB env var - and this is where you keep getting stuck. Who said anything about environment variables? Where in the question do you see OP trying to put this variable into the environment? Need I remind you of the difference between an unexported shell variable and an environment variable?
Dec
11
comment Storing longer text output in memory in shell variables vs Writing to disk
@mikeserv db2 appears to be some sort of IBM database command line utility. It is highly unlikely that nl does anything close to what it does.
Dec
11
comment Storing longer text output in memory in shell variables vs Writing to disk
@mikeserv Well obviously everything stops working if you exhaust the memory in the machine. That's why I was making the assumption that wouldn't happen. It is only about 10 MB (100k iterations * 100 chars) of data after all and everyone has 10 MB nowadays. The problem isn't running out of memory. And as I explained, you don't need to put this 10 MB shell variable in any argument lists or environments. So what exactly do you think you are running out of? We aren't passing this 10 MB shell variable to db2 if that is what you are thinking because the question doesn't say that at all.
Dec
11
comment Storing longer text output in memory in shell variables vs Writing to disk
By my understanding of the question, this "answer" is mostly off-topic and irrelevant. The first sentence gives a rough "probable" answer which I already mentioned in a comment, and the rest of it proceeds to veer off-topic into explaining why a dumb command that nobody would want to run anyways may not work.
Dec
11
comment Storing longer text output in memory in shell variables vs Writing to disk
@mikeserv Ok you've lost me. All I thought we were trying to do is put the contents of a shell variable into a file. The answer I am commenting on is suggesting /bin/echo ${VARIABLE} >> file, and I am saying that there is no reason to use /bin/echo over a shell built-in. What are you trying to do?
Dec
11
comment Storing longer text output in memory in shell variables vs Writing to disk
@mikeserv If the goal is simply to get the contents of a shell variable into a file, you don't need to use exec() functions at all. If the shell does something natively without calling any exec function, there is no argument list at all. There is no reason to try to put this shell variable into the environment.
Dec
10
comment Storing longer text output in memory in shell variables vs Writing to disk
The argument list too long problem can easily be bypassed. It's not really worth mentioning here. Who would use /bin/echo when nearly every shell has a built-in version?
Dec
10
comment Storing longer text output in memory in shell variables vs Writing to disk
@dbza Maximum size probably will not matter. As far as disk I/O goes, buffering more than a few megabytes is probably not going to improve performance. Even if a shell has an unlimited variable size, at some point you are going to run out of memory, and your kernel is going to start swapping, at which point you've probably already lost any performance benefits you might have gained.
Dec
10
comment Storing longer text output in memory in shell variables vs Writing to disk
@dbza You should try it yourself. Whether it will make a difference really depends on how slow your disk is. Another thing you can do is move the redirection outside the loop, as long as your loop doesn't output anything else.
Dec
10
comment Storing longer text output in memory in shell variables vs Writing to disk
If all you are doing is appending output to a file what is the point of putting it all in a variable first? What else are you doing with the data?
Dec
9
reviewed Close “WARNING: The character device /dev/vboxdrv does not exist.”
Dec
9
reviewed Close what the best approach in order to compress directory with Hundreds of sub directories
Dec
9
reviewed Leave Open Is there a GUI debugger for shell scripts
Dec
8
comment Sorting a file based on second column in a Tab Spaced file
Sorry, it won't let me submit without an account. If you want help you are going to have to actually tell us what the problem is.
Dec
8
comment Sorting a file based on second column in a Tab Spaced file
I typed exactly what you have in to the website and it says it worked for me.
Dec
8
comment Sorting a file based on second column in a Tab Spaced file
It's better to copy and paste the question text instead of linking to it.
Dec
8
comment How can I run a command in bash after any change in $PWD?
@NathanLong that's only for my operating system. Operating system seems irrelevant here. Does OS matter? It's the shell that matters in your question, and you seem to be specifically asking about bash, which works pretty much the same on all operating systems that it runs on.
Dec
8
revised SFTP/SCP only and chroot
Fix STRange CAPitalization.
Dec
8
comment How can I run a command in bash after any change in $PWD?
@NathanLong "how many other ways are there to change directory" - I don't know - You can find out though, because the number of shell builtins is limited and can be found in the manual.