Go Back   The UNIX and Linux Forums > Operating Systems > AIX
google site



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-10-2010
Registered User
 

Join Date: Apr 2008
Location: Mumbai,India
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Smile 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
Sponsored Links
  #2  
Old 03-10-2010
vivekraj's Avatar
Registered User
 

Join Date: Feb 2010
Location: Chennai
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
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
Registered User
 

Join Date: Apr 2008
Location: Mumbai,India
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

probably i miswrote...

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

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

Regards
Abhi
  #4  
Old 03-10-2010
Registered User
 

Join Date: Mar 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Based on the previous suggestion, you could try:


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

  #5  
Old 03-10-2010
funksen funksen is offline Forum Advisor  
Registered User
 

Join Date: Nov 2006
Location: Austria/Vienna
Posts: 494
Thanks: 1
Thanked 5 Times in 5 Posts
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
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,856
Thanks: 4
Thanked 9 Times in 9 Posts
Quote:
Originally Posted by funksen View Post
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 View Post
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
Registered User
 

Join Date: Apr 2008
Location: Mumbai,India
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
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 10:46 AM..
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Get first column from a huge string ..!! ak835 Shell Programming and Scripting 15 01-21-2010 01:21 PM
Spilt the line into two.... ak835 Shell Programming and Scripting 21 11-17-2009 03:12 PM
Huge PI in vmstat dkvent Solaris 9 08-14-2008 04:56 AM
How to spilt a file deep_kol Shell Programming and Scripting 8 11-22-2007 02:12 AM
Spilt excel file in unix Soumya Dash Shell Programming and Scripting 1 09-25-2006 02:56 AM



All times are GMT -4. The time now is 07:46 AM.