Ignore the 255 character limit of command line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ignore the 255 character limit of command line
# 1  
Old 11-18-2011
Ignore the 255 character limit of command line

Hi

I would just like to ask if there is a way for UNIX to ignore/overcome the 255 character limit of the command line?

My problem is that I have a really long line of text from a file (300+ bytes) which i have to "echo" and process by adding commands like "sed" to the end of the line, like the following:

Code:
echo "xxx really long line of text xxx" | sed -e s/xxx/yyy/g

I have read in here that there are character limits (depends on system), and tested the system I'm using and indeed, it can only process commands not exceeding 255 chars. Have also read on changing the values of ARG_MAX (limits.h) but unfortunately, my access has no permission on changing those values.

Is there a way to overcome this limit without changing system parameters? Like setting a temp buffer for the string of text/commands?

Appreciate any feedback, thanks.
# 2  
Old 11-18-2011
First of all: what OS, what shell, ...
Second: how about putting the line in a script?
This User Gave Thanks to pludi For This Post:
# 3  
Old 11-18-2011
Why not just pass the file directly to sed?
# 4  
Old 11-18-2011
Quote:
Originally Posted by pludi
First of all: what OS, what shell, ...
Second: how about putting the line in a script?
Hi pludi,

Using HP-UX, /bin/ksh.
Yes, im using a script and just doing command line to manually test, I store the line in a variable, like so:
Code:
 echo $line | sed -e 's/xxx/yyy/g'

but i still get this upon execution:
Code:
sed: Function s/xxx cannot be parsed.

I think the last parts of the command are not read anymore, due to the character limit.

Thanks.

---------- Post updated at 07:44 PM ---------- Previous update was at 07:28 PM ----------

Quote:
Originally Posted by CarloM
Why not just pass the file directly to sed?
Hi CarloM,

I'm not sure how to do that. Is there a syntax? I'm used to just piping it in after other commands.

Thanks.
# 5  
Old 11-18-2011
Just sed 'stuff' filename - runs sed on every line in the file.
# 6  
Old 11-18-2011
Just to make this clear:

There's no way to "ignore" argument length limits or argument size problems. That's a system limitation. 255 characters is an unusually severe limit, but there's always a limit. No shell syntax is ever going to fit a 10-foot truck under an 8-foot tunnel.

I've seen people pile on more and more braces, backticks, and eval until the shell stops saying "too many arguments" but it's still a 10-foot truck and 8-foot tunnel. If you made it fit, you must have wrecked the truck.

If it won't fit as an argument, you have to pass it by other means, like a file.

Last edited by Corona688; 11-18-2011 at 12:29 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Single line archive log files command if exceed certain limit in Linux

Hello Guys, Is there a single line archive command to zip or tar log files which is larger than certain size limit ? Do let me know if there is any. Thanks (7 Replies)
Discussion started by: UnknownGuy
7 Replies

2. UNIX for Beginners Questions & Answers

How to put a 80 character limit on a long topic line in markdown?

I have a topic line in markdown that spans more than 80 characters that i need to add a line break. Markdown is simply treating the line break as a brand new line instead of continuing as a topic line. Eg: # This is a very long line Markdown interprets it as This is a very long line (4 Replies)
Discussion started by: dragonpoint
4 Replies

3. UNIX for Beginners Questions & Answers

Spliting a line after 255 characters.

Hi Guys, I have a file which contains multiple lines. I need to split each line 255 characters and then I need to add call statement in the front and semi colon at the end. I/P: call sp_rebuildindex('aaa.aaa','column column column column column column column column column column ... (4 Replies)
Discussion started by: Booo
4 Replies

4. Shell Programming and Scripting

sed 255 Character Limitation

Hello, I am using sed command to place a comma dynamically in certain positions. When the position variable exceeds 255 characters, it errors out. I would appreciate if someone can point in the correct direction sed 's/^\(.\{'"$pos"'\}\)./\1,/' ragha.txt > ragha3.txt If $pos > 255,... (8 Replies)
Discussion started by: ragha81
8 Replies

5. Shell Programming and Scripting

Grep command to ignore line starting with hyphen

Hi, I want to read a file line by line and exclude the lines that are beginning with special characters. The below code is working fine except when the line starts with hyphen (-) in the file. for TEST in `cat $FILE | grep -E -v '#|/+' | awk '{FS=":"}NF > 0{print $1}'` do . . done How... (4 Replies)
Discussion started by: Srinraj Rao
4 Replies

6. Solaris

8 character limit for ipcs command , any way to increase # of chars ?

Hello All, We have a working script which identifies and kills ipcs resources which havent been correctly killed during normal shutdowns. It is working fine and dandy however there are some issues now. Environment: SunOS 5.10 Generic_148888-03 sun4u sparc SUNW,SPARC-Enterprise ... (4 Replies)
Discussion started by: icalderus
4 Replies

7. Shell Programming and Scripting

echo !SR | nc 255.255.2.2 80 - how to in XP?

Hi guys I am trying to interface with an old industrial scanner through an old PC with an old network card and a copy of Linux. It now needs to speak to a Windows XP machine, but I have no idea what the Windows equivalent of these functions would are: echo !1 | nc 255.255.2.2 80 echo ?2 | nc... (3 Replies)
Discussion started by: TonyG
3 Replies

8. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. Shell Programming and Scripting

How do I ignore one character in a case statement? PLEASE HELP!

Hello, I am new to this forums. I need help with shell, and ksh in particular. I have a case statement that does something if -k. So it looks like: case $arg in -k) PUT=y, SEND=1 Thats all good and dandy. But now I want to change it where whether or not the user puts -k or not, it will do... (2 Replies)
Discussion started by: cpunisher
2 Replies

10. UNIX for Dummies Questions & Answers

Command line buffer limit?

Is there a limit (255 chars?) on the command line?? I'm trying to copy some generated java & class files from one dir to another and ID the old & new versions by: find . -name FFSFIXADminCallbackBean.java I then do a copy and paste of the source and target - $ cp -p source target It... (7 Replies)
Discussion started by: kornshellmaven
7 Replies
Login or Register to Ask a Question