How to spilt huge string in AIX ?


 
Thread Tools Search this Thread
Operating Systems AIX How to spilt huge string in AIX ?
# 1  
Old 03-10-2010
Bug How to spilt huge string in AIX ?

I have few AIX 5.3 boxes where following is the issue.

I have a variable whose value is a very huge string ...(5000+ characters)

Code:
CMD_ARGS="/global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java -Dcom.ibm.ws.client.installedConnectors=/global/site/vendor/WAS/WebSphere6/AppServer/profiles/dmgr/installedConnectors -Dcom.ibm.CORBA.ConfigURL......................................................................................:/global/site/vendor/WAS/WebSphere6/AppServer/lib/j2ee.jar com.ncode.DMIServer.DMIMain"

Now i want to capture everything except $1 i.e in above example... "-Dcom" onwards everything....

How do i do this ?

Regards
Abhi
# 2  
Old 03-10-2010
It means,you want only the following from CMD_ARGS variable.

/global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java
If so,you try the following command.

Code:
CMD_ARGS="/global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java -Dcom.ibm.ws.client.installedConnectors=/global/site/vendor/WAS/WebSphere6/AppServer/profiles/dmgr/installedConnectors -Dcom.ibm.CORBA.ConfigURL......................................................................................:/global/site/vendor/WAS/WebSphere6/AppServer/lib/j2ee.jar com.ncode.DMIServer.DMIMain"
echo $CMD_ARGS | cut -d ' ' -f 1 #It will print the $1 as I explained above

# 3  
Old 03-10-2010
Bug

probably i miswrote...

i do not want $1.... i want rest of it...

-Dcom.... onwards everything....

Regards
Abhi
# 4  
Old 03-10-2010
Based on the previous suggestion, you could try:

Code:
echo $CMD_ARGS | cut -d ' ' -f 2-

# 5  
Old 03-10-2010
you could also use read

Code:
echo $CMD_ARGS | read FOO WHATYOUWANT

Code:
echo $WHATYOUWANT

-Dcom.ibm.ws.client.installedConnectors=/global/site/vendor/WAS/WebSphere6/AppServer/profiles/dmgr/installedConnectors -Dcom.ibm.CORBA.ConfigUR

# 6  
Old 03-10-2010
Quote:
Originally Posted by funksen
you could also use read

Code:
echo $CMD_ARGS | read FOO WHATYOUWANT

echo $WHATYOUWANT[/code]
funksen is correct. Per default the shell uses whitespace as field separator. I learned scripting on an IBM mainframe using REXX so i still follow the (there customary) convention of naming throw-away variables "." which works in ksh too. Like this:

Code:
typeset content=""
echo "word1 word2 word3 word4" | read . . content .
print - "$content"

But this sounds like a problem to me:
Quote:
Originally Posted by ak835
I have a variable whose value is a very huge string ...(5000+ characters
As far as i remember the maximum line length for a ksh input line is a system constant and is IIRC 4096 or 8192 characters. If your string is more than 5k characters long a command with this string as argument will either already fail due to shell restrictions or at least be in danger of failing if the string grows over time. The error message will be something like "argument list too long" or something such. You might want to redesign the process which leads to such extraordinary long argument lists.

I hope this helps.

bakunin
# 7  
Old 03-11-2010
Question

My problem is i am unable to test this on any of my boxes as the string is so huge...

i tried few other options and all of them work but the string i used was smaller as compared to one i am referring to.

you guys can try following options:

Code:
1> echo $CMD_ARGS |nawk '{$1=" ";sub ("^    ","");print}'

2> echo $CMD_ARGS |cut -d ' ' -f 2-

3> echo $CMD_ARGS |nawk '{print substr($0,index($0," ")+1,length($0))}'


i can't even paste that string here as it would look very weird....i m badly stuck...

by the way,i could not understand 'read' concept in above posts....can you guys explain a bit more ? (or rather paste me the code :P )

Last edited by ak835; 03-11-2010 at 11:46 AM..
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