For Programmers: Free Programming Magazines  


Home > Archive > AWK > May 2006 > AWK









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author AWK
hirenshah.05@gmail.com

2006-05-31, 6:57 pm

Hi,

I have the following text data:


PT J
C1 PENN STATE UNIV,DEPT MAT SCI & ENGN,UNIVERSITY PK,PA 16802.
RP KIKUCHI, R, UNIV CALIF LOS ANGELES,DEPT MAT SCI & ENGN,LOS
ANGELES,CA
UT ISI:A1995TD69200001
ER

PT J
RP PANDA, S, UNIV CINCINNATI,DEPT CHEM ENGN,CINCINNATI,OH 45221.
UT ISI:A1995TD69200002
ER

PT J
C1 UNIV CALCUTTA,COLL SCI & TECHNOL,DEPT APPL PHYS,CALCUTTA 700009,W
RP GHATAK, KP, UNIV CALCUTTA,COLL SCI & TECHNOL,DEPT ELECTR SCI,92
UT ISI:A1995TD69200003
ER



I want to extract the data of line starting with C1.

Can anyone tell me how to do this using AWK

Radoulov, Dimitre

2006-05-31, 6:57 pm

<hirenshah.05@gmail.com> wrote in message
news:1149096335.851793.138650@c74g2000cwc.googlegroups.com...
> Hi,
>
> I have the following text data:
>
>
> PT J
> C1 PENN STATE UNIV,DEPT MAT SCI & ENGN,UNIVERSITY PK,PA 16802.
> RP KIKUCHI, R, UNIV CALIF LOS ANGELES,DEPT MAT SCI & ENGN,LOS
> ANGELES,CA
> UT ISI:A1995TD69200001
> ER
>
> PT J
> RP PANDA, S, UNIV CINCINNATI,DEPT CHEM ENGN,CINCINNATI,OH 45221.
> UT ISI:A1995TD69200002
> ER
>
> PT J
> C1 UNIV CALCUTTA,COLL SCI & TECHNOL,DEPT APPL PHYS,CALCUTTA 700009,W
> RP GHATAK, KP, UNIV CALCUTTA,COLL SCI & TECHNOL,DEPT ELECTR SCI,92
> UT ISI:A1995TD69200003
> ER
>
>
>
> I want to extract the data of line starting with C1.
>
> Can anyone tell me how to do this using AWK


grep C1 file_name


Regards
Dimitre



Radoulov, Dimitre

2006-05-31, 6:57 pm

"Radoulov, Dimitre" <cichomitiko@gmail.com> wrote in message
news:447dd969$0$15786$14726298@news.sunsite.dk...
> <hirenshah.05@gmail.com> wrote in message
> news:1149096335.851793.138650@c74g2000cwc.googlegroups.com...
>
> grep C1 file_name


Oops :)

grep ^C1 file_name


Dimitre


Cesar Rabak

2006-05-31, 6:57 pm

hirenshah.05@gmail.com escreveu:
> Hi,
>
> I have the following text data:
>
>
> PT J
> C1 PENN STATE UNIV,DEPT MAT SCI & ENGN,UNIVERSITY PK,PA 16802.
> RP KIKUCHI, R, UNIV CALIF LOS ANGELES,DEPT MAT SCI & ENGN,LOS
> ANGELES,CA
> UT ISI:A1995TD69200001
> ER
>
> PT J
> RP PANDA, S, UNIV CINCINNATI,DEPT CHEM ENGN,CINCINNATI,OH 45221.
> UT ISI:A1995TD69200002
> ER
>
> PT J
> C1 UNIV CALCUTTA,COLL SCI & TECHNOL,DEPT APPL PHYS,CALCUTTA 700009,W
> RP GHATAK, KP, UNIV CALCUTTA,COLL SCI & TECHNOL,DEPT ELECTR SCI,92
> UT ISI:A1995TD69200003
> ER
>
>
>
> I want to extract the data of line starting with C1.
>
> Can anyone tell me how to do this using AWK
>

awk '/^C1/' your_text_file

If your platform is Unix, otherwise check your manual to see if you
won't need to change the quote marks.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com