String size limit for 'echo'...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers String size limit for 'echo'...
# 1  
Old 05-20-2014
String size limit for 'echo'...

Hi guys, man bash doesn't help much here nor does the WWW.
(I have discovered there is technically no limit to a bash array.)

I am thinking of adding a new full manual inside AudioScope.sh.

A few questions here.

The main question is, assuming I go ahead with this idea:-
Is there a limit to a string size for echo to be able to print or redirect?

It will look something like this inside single quotes used ONLY at the start and end of the string:-
Code:
..........First part of AudioScope.sh script.
# Start of manual...
echo 'Some huge file
with lots of punctuation, typos
and newlines. It could be 200kB or more in size and will sit
anywhere of my choice inside the code.' > AudioScope.Manual
# Save to the current drawer
# End of manual...
..........Last part of AudioScope.sh script.

I already know that technically there is no limit to the script size itself but this is different.
Once saved there will be a command call to 'less' inside the script if required to read the file generated.

Assuming this can be done then is it possible to delete the lines from the LIVE running script, from..........
# Start of manual... to # End of manual...
..........and then resave the running script less all of these lines on the fly?
In essence, a self editing facility on the first run only...

(TIA and hope this is lucid enough.)
# 2  
Old 05-20-2014
Use a here-document for this. It's some of the syntax you've been avoiding to keep things simple, but is intended exactly for situations like this.

Code:
cat <<"EOF" > /tmp/whatever
text
text
more text
stuff
EOF

As for editing the script on-the-fly, while you're using it? No. Bad idea. The file isn't 'cached', you will be ripping it out from under the shell...
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 05-21-2014
Hi Corona688...

Thanks, advice taken and will be implemented once I have a working manual...
# 4  
Old 05-21-2014
I believe that the limit is ARG_MAX getconf ARG_MAX.

Depending on your OS, the limit is 1 or 2 megabytes, possibly more.
# 5  
Old 05-21-2014
Quote:
Originally Posted by Peasant
I believe that the limit is ARG_MAX
echo is usually a shell built-in and not subject to that limit.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 6  
Old 05-21-2014
Keep in mind, though, that the more stuff you put into a script the more has to be loaded once it is called. Modifying a script during runtime is a VERY BAD idea, like Corona688 already noted.

Why not create a man page? This is the intended place for such kind of information and would allow for inclusion of some text markup (using "troff"s "man" macro package) and make the information better accessible.

I hope this helps.

bakunin
# 7  
Old 05-21-2014
Quote:
Originally Posted by bakunin
Keep in mind, though, that the more stuff you put into a script the more has to be loaded once it is called.

Why not create a man page? This is the intended place for such kind of information and would allow for inclusion of some text markup (using "troff"s "man" macro package) and make the information better accessible.
I know the script will eventually be large and that was the intention.
Everything relevant should be in the one script, (it is even possible to break the images down as data but I don't intend to do it ;o) ).

As both you and Corna688 have emphasised the point, am not going to do a _self_edit_ of the script but let the public who are interested in it edit manually for themselves.

I had thought about a (pseudo) man page but I have decided not to as yet.

I had thought about editing the script file itself from disk while using the script with the code required inside the script but have abandoned that idea too.

However the "here-document" approach appeals to me and I will experiment with that first.

Thanks to all for your comments, next upload of AudioScope.sh is imminent.

As it is now fairly big I will make it an attachment only...

Cheers guys and once again thanks.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here. I have following script (called out_to_streams.csh): #!/bin/tcsh -f echo Redirected to STDOUT > /dev/stdout echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies

2. Shell Programming and Scripting

Limit on a File size.

Hi All, I want to store 32KB of file in Oracle DB into CLOB field. I am not able to insert more than 32KB of file into CLOB. So i want to put a limit on the file size. I am using k shell. My file size will dynamically increase its size, i want to check the file size if it is more than 32KB... (1 Reply)
Discussion started by: rajeshorpu
1 Replies

3. UNIX for Advanced & Expert Users

file size limit?

hi, how can I find out what the limit of a file size is on unix? thanks (6 Replies)
Discussion started by: JamesByars
6 Replies

4. UNIX for Advanced & Expert Users

logrotate size limit

Hi i configured log rotate for a specific file. /var/log/sauer i configured create a file in logrotate.d # cat /etc/logrotate.d/sauer #this is a logrotate configuration file for msu_ng logs /var/log/sauer { rotate 5 size=1M daily compress ... (5 Replies)
Discussion started by: modcan
5 Replies

5. Linux

Limit directory size

Hello I want to limit the size of a directory; so a user cant copy more staff inside it then 5 Giga for example.. eg. /nfs/temp/jhon size can not increase more that 5Gb I havnt found anything on the net. Is there a way to do it? (2 Replies)
Discussion started by: jredx
2 Replies

6. UNIX for Dummies Questions & Answers

can I limit the size of a directory?

Hi, I am not root, but I need to limit the size of my directory, so that it cannot contain more than 200M of stuff inside. Is this possible? Also, how can I see the total size of that directory? If I do ls -ltrd, it does not give me the size of all the files inside the directory. And if I do df... (6 Replies)
Discussion started by: JamesByars
6 Replies

7. UNIX for Advanced & Expert Users

File Size Limit

Hi, I have a problem writing or copying a file 2GB or larger to either the second or third disk on my C8000. I've searched this forum and found some good information on this but still nothing to solve the problem. I'm running hpux 11i, JFS3.3 and disk version 4 (from fstyp) on all 3 disks. ... (2 Replies)
Discussion started by: HaidoodFaulkauf
2 Replies

8. AIX

file size limit

Can anybody help me? How to increase file size limit in aix 5.2? I have already specified in /etc/security/limits file : default: fsize = -1 core = 2097151 cpu = -1 data = -1 rss = -1 stack = -1 nofiles = 2000 (2 Replies)
Discussion started by: vjm
2 Replies

9. Solaris

File size limit

I want to have a permanent file created - and limit the size that this file can grow.. I want a circular file.. ie max size of file is 10 mb.. and if any new data written to file the oldest data removed.. How can I do this? I am on solaris 9 x86 (3 Replies)
Discussion started by: frustrated1
3 Replies

10. UNIX for Dummies Questions & Answers

Limit size of the file

How do I limit size of a file to 1 MB or something like that under Linux? (4 Replies)
Discussion started by: _hp_
4 Replies
Login or Register to Ask a Question