Extract data correction???


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extract data correction???
# 1  
Old 09-26-2006
Extract data correction???

Hi

I have file "test.txt"

i need to extract the data as below from this file.

/home/cvs/gkc ->awk -v RS= '{print $(NF-2),$(NF-1),$NF}' test.txt
Buildfile: build.xml Buildfile: build.xml
Created dir: /dist/advance/2.0.4/20060926-0413
awk: The field -1 must be in the range 0 to 199.

The input line number is 3. The file is test.txt.
The source line number is 1.

I am getting all of the above errors i need only the following /dist/advance/2.0.4/20060926-0413 from that file without any spaces.
so that i will be using this data in another command.

can some one correct the above...
# 2  
Old 09-26-2006
can you tell us what the input file contains ?
what are you trying to do?
# 3  
Old 09-27-2006
my test.txt files contains the following data

create-tar:
[echo] Module : source-fileLayouts
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-fileLayouts.tar
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-broker.tar
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-userExits.tar
[exec] ./cobbuff/co*ed* not found
[exec] ./cobbuff/db*ed* not found
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-userExits.tar.gz
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-userExits.tar
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-fileLayouts.tar.gz
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-fileLayouts.tar
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-broker.tar.gz
[exec] ./coblist/co*ed* not found
[exec] ./coblist/db*ed* not found
[exec] ./cobsize/co*ed* not found
[exec] ./cobsize/db*ed* not found
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-broker.tar
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-reports.tar
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-reports.tar.gz
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-advance.tar
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-reports.tar
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-advance.tar.gz
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-advance.tar

create-tar:
[echo] Module : source-ccms

create-tar:
[echo] Module : source-crms

create-tar:

create-tar:
[echo] Module : source-codeReview
[echo] Module : source-claimCheck
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-ccms.tar
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-ccms.tar.gz
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-crms.tar
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-codeReview.tar
[tar] Building tar: /dist/advance/2.0.4/20060926-0413/source-claimCheck.tar
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-crms.tar.gz
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-claimCheck.tar.gz
[gzip] Building: /dist/advance/2.0.4/20060926-0413/source-codeReview.tar.gz
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-ccms.tar
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-crms.tar
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-claimCheck.tar
[delete] Deleting: /dist/advance/2.0.4/20060926-0413/source-codeReview.tar

BUILD SUCCESSFUL
Total time: 8 minutes 11 seconds
************************************************

i need only /dist/advance/2.0.4/20060926-0413 with out any spaces from the above file
# 4  
Old 09-27-2006
I think you are looking for something like this:
Code:
grep /dist/advance/2.0.4/20060926-0413 test.txt | tr -d ' '

Output:
Code:
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-fileLayouts.tar
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-broker.tar
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-userExits.tar
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-userExits.tar.gz
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-userExits.tar
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-fileLayouts.tar.gz
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-fileLayouts.tar
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-broker.tar.gz
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-broker.tar
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-reports.tar
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-reports.tar.gz
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-advance.tar
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-reports.tar
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-advance.tar.gz
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-advance.tar
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-ccms.tar
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-ccms.tar.gz
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-crms.tar
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-codeReview.tar
[tar]Buildingtar:/dist/advance/2.0.4/20060926-0413/source-claimCheck.tar
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-crms.tar.gz
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-claimCheck.tar.gz
[gzip]Building:/dist/advance/2.0.4/20060926-0413/source-codeReview.tar.gz
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-ccms.tar
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-crms.tar
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-claimCheck.tar
[delete]Deleting:/dist/advance/2.0.4/20060926-0413/source-codeReview.tar

# 5  
Old 09-27-2006
Hi

Hi

when i run that comamnd i get
grep /dist/advance/2.0.4/20060926-0413 test.txt | tr -d ' '
all the releated path.. in the file.

Conditons:
1) I need to dipslay only one line from the above file.
like when i run my script i need to get as below
/dist/advance/2.0.4/20060926-0413 with out any spaces.

2) "/2.0.4/20060926-0413 " will be changing ..for different files.

i will be using the output in another script as a variable.
# 6  
Old 09-27-2006
Try...
Code:
eval $(awk 'match($0,/\/dist\/advance\/[^\/]+\/[^\/]+/){print "var=" substr($0,RSTART,RLENGTH);exit}' test.txt)
echo $var

# 7  
Old 09-27-2006
Hi

That works..

Can you please explain me the above
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk correction

if awk 'BEGIN{if('$RSS'>='1000')exit 0;exit 1}' ; then dowhatever fi the above code works great when i'm comparing numerical figures. but when i try to do a string comparison, it does not work: if awk 'BEGIN{ /'$RSS'/ ~ /DB01/ exit 0;exit 1}' ; then dowhatever fi can this... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

While loop correction

I am checking if ssh is working fine on remote server proceed for next step until keep check ssh port, below is shell script. #!/bin/bash MON="SSH" x=1 while do echo "SSH Checking Status" nc 192.168.1.20 -w 2 done (3 Replies)
Discussion started by: learnbash
3 Replies

3. Shell Programming and Scripting

Extract header data from one file and combine it with data from another file

Hi, Great minds, I have some files, in fact header files, of CTD profiler, I tried a lot C programming, could not get output as I was expected, because my programming skills are very poor, finally, joined unix forum with the hope that, I may get what I want, from you people, Here I have attached... (17 Replies)
Discussion started by: nex_asp
17 Replies

4. UNIX for Dummies Questions & Answers

Correction in Syllabus

Sir, I have the following modules to learn. The details of the modules in the syllabus published by the university are given below. There are some huge spelling mistakes in the syllabus. I have corrected few of them. Can u please quote the spelling mistakes in the syllabus if any and kindly... (1 Reply)
Discussion started by: achuthmama
1 Replies

5. Shell Programming and Scripting

small script correction

input cz1 87942437 87952030 M_001144992 0 + 87942537 87949664 0 3 710,114,2506, 0,2725,7087, script awk '{ n11 = split($11, t11, ",") n12 = split($12, t12, ",") for (i = 0; ++i < n11;) { s12 = $2 + t12 print $4"_xon"i, "\t",$4"_xon"i,"\t", $1,... (1 Reply)
Discussion started by: quincyjones
1 Replies

6. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

7. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

8. Shell Programming and Scripting

how to extract the data ?

Hi, I'm trying to pick out a data field eg. from below. I need the required field as below but they are filled sometimes with weird chars like \-(. or watever. How can I accurately extract the 3rd field in shell? :confused: ID IDNO - REQUIRED FIELD ID 1447 - MAT620BR. ID 1452 -... (13 Replies)
Discussion started by: uxnoob
13 Replies

9. Shell Programming and Scripting

extract data from a data matrix with filter criteria

Here is what old matrix look like, IDs X1 X2 Y1 Y2 10914061 -0.364613333 -0.362922333 0.001691 -0.450094667 10855062 0.845956333 0.860396667 0.014440333 1.483899333... (7 Replies)
Discussion started by: ssshen
7 Replies

10. UNIX for Dummies Questions & Answers

End of Error correction

I am being told by serveral different departmens that serveral of the products we use such as Oracle, IONA orbix 3.0, Veritas NetBackup and Tivoli Maestro are about to end support of Error Correction Support. Could some please help me understand what this actually means. Thanks Kristian (1 Reply)
Discussion started by: kristian
1 Replies
Login or Register to Ask a Question