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 ..!!
# 8  
Old 01-20-2010
what about ?
Code:
cut -d' ' -f1

# 9  
Old 01-20-2010
ak835. Judging from that last post, are you are trying to find out the full program path for PID 29040 only?
If so, part of the problem is that you are processing details for every process when "ps" can give you the details for one process.

I too wonder where the timeout comes from. Are you using a remote shell?

On the surface the simple way to deal with a long string is to put it in a file (rather than an environment variable) and then process it totally in a programming language.

Last edited by methyl; 01-20-2010 at 12:52 PM.. Reason: More
# 10  
Old 01-20-2010
Code:
set $CMD

Will place what you want in the positional parameter $1.

Code:
$ echo $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

$ set $CMD

$ echo $1
/global/site/vendor/Vignette7/Content/7_5/java5/jre/bin/java

Regards,
Alister
# 11  
Old 01-20-2010
Code:
$ 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'

$ echo ${cmd%% *}
/global/site/vendor/Vignette7/Content/7_5/java5/jre/bin/java

# 12  
Old 01-20-2010
Hi.

These are all good solutions, but let's not forget the "dirname" part of the original question Smilie
# 13  
Old 01-20-2010
Hello ,

In perl I would accomplish this,
Code:
perl -wlna -e 'print $F[0]'

Regards,
# 14  
Old 01-20-2010
Computer

why not ?

Code:
cut -f1 -d' ' | cut -f2-40 -d'/'

just increase 40 if the dirname have so many char. SmilieSmilie
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