Get first column from a huge string ..!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get first column from a huge string ..!!
# 1  
Old 01-20-2010
Bug Get first column from a huge string ..!!

Guys

Look at the following string....!!


Code:
/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 -DVgnClassPathFile=/global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1/conf/cfa.classpath -Xms32m -Xmx128m -Dcom.vignette.workingDir=/global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1 -Dcom.vignette.installDir=/global/site/vendor/Vignette7/Content/7_5 -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dorg.apache.commons.logging.Log=com.vignette.logging.CommonsLogger com.vignette.config.launcher.vgnlauncher -c /global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1/conf/cfa.cfg -i /cs/config.cfa-V7CDS1CA1



From this huge string ,i just need
Code:
global/site/vendor/Vignette7/Content/7_5/java5/jre/bin/java

I have already tried ,but failed with

1.awk '{print $1}'
2.nawk '{print $1}'
3.nawk -F ' ' '{print $1}'


Any ideas/clues?

Regards
Abhi
# 2  
Old 01-20-2010
Hi.

The first awk works fine. What error do you get (and what OS are you using)?
# 3  
Old 01-20-2010
Bug

I am getting a time out error.

I am trying to do following on Solaris 5.10

Code:
CMD=<first huge string i pasted>
A=$(echo $CMD |nawk -F ' ' '{print $1}')

B=`dirname $A`

if [ $B = "." ]
then
echo ""
else
echo $B
fi

# 4  
Old 01-20-2010
Code:
$
$ HUGE_STRING="/global/site/vendor/Vignette7/Content/7_5/java5/jre/bin/java -classpath /global/site/vendor/Vi
gnette7/Content/7_5/lib/vgnconfiglauncher.jar -Dcom.vignette.jvmid=V7CDS1CA1 -DVgnStartupClass=com.vignette.c
onfig.agent.Agent -DVgnClassPathFile=/global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1/conf/cfa.classpath -
Xms32m -Xmx128m -Dcom.vignette.workingDir=/global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1 -Dcom.vignette.
installDir=/global/site/vendor/Vignette7/Content/7_5 -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xe
rces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFac
toryImpl -Dorg.apache.commons.logging.Log=com.vignette.logging.CommonsLogger com.vignette.config.launcher.vgn
launcher -c /global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1/conf/cfa.cfg -i /cs/config.cfa-V7CDS1CA1"
$
$
$ echo $HUGE_STRING | perl -lane '{print $F[0]}'
/global/site/vendor/Vignette7/Content/7_5/java5/jre/bin/java
$
$

tyler_durden
# 5  
Old 01-20-2010
Hmm.

In Solaris 10, it works with nawk

Code:
# cat Test
CMD="/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 -DVgnClassPathFile=/global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1/conf/cfa.classpath -Xms32m -Xmx128m -Dcom.vignette.workingDir=/global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1 -Dcom.vignette.installDir=/global/site/vendor/Vignette7/Content/7_5 -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dorg.apache.commons.logging.Log=com.vignette.logging.CommonsLogger com.vignette.config.launcher.vgnlauncher -c /global/site/vendor/Vignette7/Content/7_5/V7CDS1CA1/conf/cfa.cfg -i /cs/config.cfa-V7CDS1CA1"

A=$(echo $CMD | nawk '{print $1}')

B=`dirname $A`

if [ $B = "." ]
then
echo ""
else
echo $B
fi
# ./Test
/global/site/vendor/Vignette7/Content/7_5/java5/jre/bin

Is that the actual string you used? How long until this "time out"? Can you run the script, and post the output, including the error?
# 6  
Old 01-20-2010
Tools Put in an intermediate marker

After setting A, do an
Code:
echo $A

just to make sure that line is where the 'time-out' is occurring.

It would help isolate the problem because in theory anyway, that second command could be the culprit.
# 7  
Old 01-20-2010
Bug

dodge this....!!

Code:
0 0 root  29040 1 0 59 20330440311536 30000c031dc S ? 919:55 /global/site/vendor/WAS/WebSphere7/AppServer/java/bin/java -XX:+UnlockDiagnosticVMOptions -Dwas.status.socket=47077 -XX:+UnsyncloadClass -XX:MaxPermSize=256m -Declipse.security -Dosgi.framework.extensions=com.ibm.ws.eclipse.adaptors -Dosgi.install.area=/global/site/vendor/WAS/WebSphere7/AppServer -Dosgi.configuration.area=/global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01/configuration -Djava.awt.headless=true -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -Xbootclasspath/p:/global/site/vendor/WAS/WebSphere7/AppServer/java/jre/lib/ext/ibmorb.jar:/global/site/vendor/WAS/WebSphere7/AppServer/java/jre/lib/ext/ibmext.jar -classpath /global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01/properties:/global/site/vendor/WAS/WebSphere7/AppServer/properties:/global/site/vendor/WAS/WebSphere7/AppServer/lib/startup.jar:/global/site/vendor/WAS/WebSphere7/AppServer/lib/bootstrap.jar:/global/site/vendor/WAS/WebSphere7/AppServer/lib/jsf-nls.jar:/global/site/vendor/WAS/WebSphere7/AppServer/lib/lmproxy.jar:/global/site/vendor/WAS/WebSphere7/AppServer/lib/urlprotocols.jar:/global/site/vendor/WAS/WebSphere7/AppServer/deploytool/itp/batchboot.jar:/global/site/vendor/WAS/WebSphere7/AppServer/deploytool/itp/batch2.jar:/global/site/vendor/WAS/WebSphere7/AppServer/java/lib/tools.jar -Dibm.websphere.internalClassAccessMode=allow -Xms50m -Xmx256m -Dws.ext.dirs=/global/site/vendor/WAS/WebSphere7/AppServer/java/lib:/global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01/classes:/global/site/vendor/WAS/WebSphere7/AppServer/classes:/global/site/vendor/WAS/WebSphere7/AppServer/lib:/global/site/vendor/WAS/WebSphere7/AppServer/installedChannels:/global/site/vendor/WAS/WebSphere7/AppServer/lib/ext:/global/site/vendor/WAS/WebSphere7/AppServer/web/help:/global/site/vendor/WAS/WebSphere7/AppServer/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime -Dderby.system.home=/global/site/vendor/WAS/WebSphere7/AppServer/derby -Dcom.ibm.itp.location=/global/site/vendor/WAS/WebSphere7/AppServer/bin -Djava.util.logging.configureByServer=true -Duser.install.root=/global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01 -Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder -Dwas.install.root=/global/site/vendor/WAS/WebSphere7/AppServer -Dpython.cachedir=/global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01/temp/cachedir -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager -Dserver.root=/global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01 -Dcom.ibm.security.jgss.debug=off -Dcom.ibm.security.krb5.Krb5Debug=off -Djava.security.auth.login.config=/global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01/properties/wsjaas.conf -Djava.security.policy=/global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01/properties/server.policy com.ibm.wsspi.bootstrap.WSPreLauncher -nosplash -application com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer /global/site/vendor/WAS/WebSphere7/AppServer/profiles/JobMgr01/config clmsd027JobMgrCell01 clmsd027JobMgr01 jobmgr

I have written code like this:

Code:
A=$(/usr/ucb/ps -alxww | nawk '$2 != "UID" { printf("%s %s ",$1,$2);system("getent passwd "$2"| sed s/:.*$// | tr -d \\\\n");$1=""; $2=""; print $0 }$2 == "UID" { $2="UID USER"; print }'|nawk -F' ' '{ if($4 == "29040"){substr("^    ","");print}}')

B=$(echo "$A" |nawk '{print substr($0,index($0,":")+3,length($0))}'|nawk -F ' ' '{print $1}')

C=$(dirname "$B")

if [ $C = "." ]
then
echo ""
else
echo $C
fi

no error...my engine simply got exhausted ...i am not sure if its bcoz of string size or i have written something wrong above [though it works fine now for the earlier huge string i had pasted ]


give me something which will give me first column ,irrespective of the string length,size etc....

help me out guys !!



Regards
Abhi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Column 2 string count in Column 3

My I/p is Col1|Col2|Col3 2116209997932|POSIX INC|POSIX 2116209997933|POSIX INC|POSIX 2116210089479|POSIX INC|POSIX 2116210180502|POSIX INC|POSIX 2116210512279|POSIX INC|Aero 2116210516838|POSIX INC|POSIX 2116210534342|POSIX INC|postal 2116210534345|POSIX INC|postal ... (6 Replies)
Discussion started by: nikhil jain
6 Replies

2. Shell Programming and Scripting

Use a string in one column to get the largest or the smallest of another column

I have data that looks like this: chr1 mm9_knownGene exon 155747075 155747189 0.000000 + . gene_id "Glul"; transcript_id "uc007daq.1"; chr1 mm9_knownGene exon 155750064 155750076 0.000000 + . gene_id "Glul";... (3 Replies)
Discussion started by: pbluescript
3 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

Copy column string and put in different column

Hello Here is my input: SU3902 SU3902A NS29C (10) (00) Q1J1 0 SU3902 SU3902B VLR05 (20) (02) Q2H1 4 SU3902 SU3902C NBR22 (30) (06) Q3R5 8 SU3904 SU39047 NSV19 (11) (09) Q4k6 2 SU3904 SU39048 LB231 (12) (05) Q5k1 6 SU3904 SU39049 11VLT (13) (08) Q10C1 10 SU3904 SU3904A 25R05 (15) (06)... (3 Replies)
Discussion started by: pareshkp
3 Replies

5. Shell Programming and Scripting

convert huge .xml file in .csv with specific column.

I have huge xml file in server and i want to convert it to .csv with specific column ... i have search in blog but i didn't get any usefully command. Thanks in advance (1 Reply)
Discussion started by: pareshkp
1 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. AIX

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) CMD_ARGS="/global/site/vendor/WAS/WebSphere6/AppServer/java/bin/java... (7 Replies)
Discussion started by: ak835
7 Replies

8. UNIX for Advanced & Expert Users

Replace string in column

Hi, I want to replace string in column,Example i have file caleed a1.txt ,want to replace string "A12" with "A23" only in column2 ,not from file itself.Using sed command replace string in file itself. Thanks, Mohan (3 Replies)
Discussion started by: mohan705
3 Replies

9. Shell Programming and Scripting

Search in a column by a string

Hi All, My file looks like : hsdhj dsajhf jshdfajkh jksdhfj jkdhsfj shfjhd shdf hdsfjkh jsdfhj hdshf sdjh dhs foot dsjhfj jdshf dasfh jdsh dsjfh jdfshj david Now, I want to search entire column by a string... (10 Replies)
Discussion started by: naw_deepak
10 Replies

10. Shell Programming and Scripting

string validation on a column

Hi there I have a file that I recieve that looks like the folowing, As these details are being manually entered by the customer, we sometimes get a few typos on 4th column (the 14 digit number starting with 42....) As you can see the first one has a space as the first character and then a 13 number... (3 Replies)
Discussion started by: hcclnoodles
3 Replies
Login or Register to Ask a Question