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 ..!!
# 15  
Old 01-21-2010
MySQL

thanks for all these wonderful responses...!!

here is what i see working for me...

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 == "@@Host Processes.PID@@"){substr("^    ","");print}}')

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

set $CMDP

C=$(echo $1)

D=`dirname $C`

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

Scrutinizer:
When i saw what you wrote ,i felt that should work for me but a strange thing happens..look below

Code:
bash-3.00$ 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}}')

bash-3.00$ CMDP=$(echo "$A" |nawk '{print substr($0,index($0,":")+3,length($0))}')

bash-3.00$ echo $CMDP
/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

bash-3.00$ echo ${CMDP%% *}

It did not work out of code line.If i set it manually on command prompt ,then it works.
Thanks anyway !!


Perl is out of question,thanks for the suggestions though !!

I am still testing it and will keep posted .

Regards
Abhi
# 16  
Old 01-21-2010
Code:
 
CMD="/global/site/............/cs/config.cfa-V7CDS1CA1"
newCMD=$(echo $CMD | awk -F/bin '{print $1}')

o/p

Code:
echo $newCMD
/global/site/vendor/Vignette7/Content/7_5/java5/jre

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