How to fetch specific fields


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to fetch specific fields
# 1  
Old 07-04-2012
Question How to fetch specific fields

Dear Friends,

Please provide some commands to fecth specific filed (data yellow color) from below data..

Input data
Code:
2648: 1;20120707;3591|4;20290107;90|5;20290107;3|9;20120705;0|10;20120705;0|16;20290113;15|29;20120705;0
2658: 1;20120722;0|4;20290422;1200|9;20120705;0|10;20120705;0
2646: 1;20120727;328|4;20291027;690|9;20120705;0|10;20120705;0|11;20120720;0|16;20291027;2|18;20120705;0|19;20120705;0|29;20120705;0
2650: 1;20120713;370.4|9;20120705;0|10;20120705;0|11;20120706;0|16;20291013;29|18;20120705;0|29;20120705;0


required Output
Code:
2648: 10;20120705;0
2658: 10;20120705;0
2646: 10;20120705;0
2650: 10;20120705;0


Thanks
Suresh

Last edited by Scrutinizer; 07-04-2012 at 05:35 AM..
# 2  
Old 07-04-2012
What is the criterion, that the field starts with 10; ?
# 3  
Old 07-04-2012
Hi

Assuming you want fields starting with 10;


Code:
$ awk -F"[:|]" '{for(i=1;i<=NF;i++)if($i ~ /^10;/)print $1": "$i;}' file
2648: 10;20120705;0
2658: 10;20120705;0
2646: 10;20120705;0
2650: 10;20120705;0

Guru
# 4  
Old 07-04-2012
Code:
sed 's/ .*|10;/ 10;/;s/|.*//' file

# 5  
Old 07-04-2012
Thank U Guru & Scrutinzer.. both commands are working..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to fetch specific data from a file.?

Hi , I have a file which contains 2 days logs(here it is 24 and 25) I want to list data only for date 25 fron the file. please suggest me how should i get this. file content mentioned below 17-05-24 Name Succ Fail 00:00:29 ... (5 Replies)
Discussion started by: scriptor
5 Replies

2. Shell Programming and Scripting

Fetch entries with specific pattern

Hi all, I have following sample input file which is a part of big file: ID AINX_HUMAN Reviewed; 499 AA. AC Q16352; B1AQK0; Q9BRC5; DT 30-MAY-2000, integrated into UniProtKB/Swiss-Prot. DT 23-JAN-2002, sequence version 2. DT 28-NOV-2012, entry version 123.... (2 Replies)
Discussion started by: kareena
2 Replies

3. Shell Programming and Scripting

Fetch specific entries

Hi Guys This time my input sample from a Big file like this In TTDS00002 UniProt ID P11229 TTDS00002 Name Muscarinic acetylcholine receptor M1 TTDS00002 Type of target Successful target TTDS00002 Synonyms M1 receptor TTDS00002 Disease Alzheimer's disease... (13 Replies)
Discussion started by: Priyanka Chopra
13 Replies

4. Shell Programming and Scripting

Fetch entries in front of specific word till next word

Hi all I have following file which I have to edit for research purpose file:///tmp/moz-screenshot.png body, div, table, thead, tbody, tfoot, tr, th, td, p { font-family: &quot;Liberation Sans&quot;; font-size: x-small; } Drug: KRP-104 QD Drug: Placebo Drug: Metformin|Drug:... (15 Replies)
Discussion started by: Priyanka Chopra
15 Replies

5. Shell Programming and Scripting

Search specific name in a file and fetch specific entries

Hi all, I have 2 files, One file contain data like this FHIT CS CHRM1 PDE3A PDE3B HSP90AA1 PTK2 HTR1A ESR1 PARP1 PLA2G1B These names are mentioned in the second file(Please see attached second file) as (7 Replies)
Discussion started by: manigrover
7 Replies

6. Shell Programming and Scripting

Urgent request to consider:Search specific name in a file and fetch specific entries

Hi all, I have 2 files, One file contain data like this FHIT CS CHRM1 PDE3A PDE3B HSP90AA1 PTK2 HTR1A ESR1 PARP1 PLA2G1B These names are mentioned in the second file(Please see attached second file) as # Drug_Target_X_Gene_Name:(Where X can be any number (1-1000) (1 Reply)
Discussion started by: manigrover
1 Replies

7. Shell Programming and Scripting

fetch last line no form file which is match with specific pattern by grep command

Hi i have a file which have a pattern like this Nov 10 session closed Nov 10 Nov 9 08:14:27 EST5EDT 2010 on tty . Nov 10 Oct 19 02:14:21 EST5EDT 2010 on pts/tk . Nov 10 afrtetryytr Nov 10 session closed Nov 10 Nov 10 03:21:04 EST5EDT 2010 Dec 8 Nov 10 05:03:02 EST5EDT 2010 ... (13 Replies)
Discussion started by: Himanshu_soni
13 Replies

8. Shell Programming and Scripting

How to fetch a specific line from file

Hi, I have text file in the following strucher . The files contain hondreds of lines. value1;value2;value3;value4 I would like to get back the line with lowest date (values4 field). In this case its line number 3. groupa;Listener;1;20110120162018 groupb;Database;0;20110201122641... (4 Replies)
Discussion started by: yoavbe
4 Replies

9. Shell Programming and Scripting

To fetch specific words from a file

Hi All, I have a file like this,(This is a sql output file) cat query_file 200000029 12345 10001 0.2 0 I want to fetch the values 200000029,10001,0.2 .I tried using the below code but i could get... (2 Replies)
Discussion started by: girish.raos
2 Replies
Login or Register to Ask a Question