How to spilt huge string in AIX ?


 
Thread Tools Search this Thread
Operating Systems AIX How to spilt huge string in AIX ?
# 8  
Old 03-15-2010
so lets create a variable to test your requirements:

switch to ksh93, since ksh can't handle a for loop with a syntax like this:

Code:
ksh93
CMD_ARGS=$(for ((i=0;i<20000;i++)) ; do [[ $i = 5 ]] && printf " " ; printf a  ; done )

this little script sets the variable CMD_ARGS to

Code:
echo $CMD_ARGS
aaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...................... (19995 times)



Code:
echo $CMD_ARGS | read . WHATYOUWANT
(thanks bakunin for that, didn't know that it's possible to use . as variable name ;))
echo $WHATYOUWANT


gives you 19995 times a, so it's possible with read

the maximum size of command arguments on AIX, is set with the ncargs attribute, listed as option of sys0

Code:
lsattr -El sys0 -a ncargs

default on my systems is 6, so you have 6x4k blocks=24k=24k characters

if I set the variable to 30k times a, I get the following error message, for every command I want to run:

Code:
ksh93: /bin/ls: cannot execute.
[The parameter or environment lists are too long.].


set ncargs to 16 for example, then you wont have problems


and @ ak835:

from the man page of read:

Quote:
Description

The read command reads one line from standard input and assigns the values of each field in the input line to a shell variable using the characters in the IFS (Internal Field Separator) variable as separators. The VariableName
parameter specifies the name of a shell variable that takes the value of one field from the line of input. The first shell variable specified by the VariableName parameter is assigned the value of the first field, the second
shell variable specified by the VariableName parameter is assigned the value of the second field, and so on, until the last field is reached. If the line of standard input has more fields than there are corresponding shell
variables specified by the VariableName parameter, the last shell variable specified is given the value of all the remaining fields. If there are fewer fields than shell variables, the remaining shell variables are set to empty
strings.
to make sure, set the ifs to " ", before running the read command
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String operation in csh AIX 4.3.2.0

Hi to everybody i stuck on a simple thing i had a string and i want cut it , i try already few thing with the cut command but does not the way it should. The script is in csh and running on AIX 4.3.2.0 here are few samples how the string can look like FT71;1;1;1;;;1;31.01.2017... (9 Replies)
Discussion started by: Nadielosabra
9 Replies

2. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

3. Shell Programming and Scripting

string replace in huge file

I need to parse a huge file... with some strings like this: <li class="website-feature"><a href="http://some.changingurl.com" ..(some changing classes)..> I need to change the above to: <li class="website-feature">http://some.changingurl.com<a href="http://some.changingurl.com" ..(some... (2 Replies)
Discussion started by: dtdt
2 Replies

4. Shell Programming and Scripting

aix :grep to get lines before and after string

am using AIX and I have a string "There is no process to read data written to a pipe". I want to get the output 2 lines before and 4 lines after this string. The string is present like more than 100 times in the log and I want to output, the last result in the log with this string I tried using... (1 Reply)
Discussion started by: PhAnT0M
1 Replies

5. AIX

Error while copying huge amount of data in aix

Hi When i copy 300GB of data from one filesystem to the other filesystem in AIX I get the error : tar: 0511-825 The file 'SAPBRD.dat' is too large. The command I used is : # tar -cf - . | (cd /sapbackup ; tar -xf - ) im copying as root The below is my ulimit -a output : ... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

6. Shell Programming and Scripting

search a string in a huge file

How to search a string which has occured numerous times in a single row. I tried many options, I am facing issue with the file size. Anything I go for, it says it is huge.. File is 82MB. Assume, the file contains the string 'Name' in many places.. Something Like below. ... (5 Replies)
Discussion started by: Muthuraj K
5 Replies

7. Shell Programming and Scripting

Get first column from a huge string ..!!

Guys Look at the following string....!! /global/site/vendor/Vignette7/Content/7_5/java5/jre/bin/java -classpath /global/site/vendor/Vignette7/Content/7_5/lib/vgnconfiglauncher.jar -Dcom.vignette.jvmid=V7CDS1CA1 -DVgnStartupClass=com.vignette.config.agent.Agent... (15 Replies)
Discussion started by: ak835
15 Replies

8. Shell Programming and Scripting

Spilt the line into two....

Hello Guys /usr/local/sbin/sshd I need to spilt such a line like this Path to be set as :/usr/local/sbin Command to be set as : sshd What combination should i use? Regards Abhi (21 Replies)
Discussion started by: ak835
21 Replies

9. Shell Programming and Scripting

How to spilt a file

Hi , I have a file,abc.txt. like abc.txt ======= KOKRS EL01 RLDNR M2 RRCTY 1 Company Code 100 ... (8 Replies)
Discussion started by: deep_kol
8 Replies

10. Shell Programming and Scripting

Spilt excel file in unix

Hi friends... I am sending a file say xyz.xls to a mail through unix. The .xls file is more than 65 thousand in size so I want to spilt the file size into 40 thousand and 25 thousand. So can anyone provide any inputs.... (1 Reply)
Discussion started by: Soumya Dash
1 Replies
Login or Register to Ask a Question