Extracting a column using AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting a column using AWK
# 1  
Old 08-02-2007
Extracting a column using AWK

Hi,

I've a text file like

Code:
ABC,,100
A,100,200

In the above example, I have 3 columns. I want to extract the second column.

I'm expecting a value like
Code:
100

i.e first record will not have any value but still it has to give me null value. second record should give 100.

Can anybody suggest me the solution using awk?

Ronald.
# 2  
Old 08-02-2007
Code:
nawk -F',' '{print $2}' myFile

# 3  
Old 08-02-2007
Thanks a lot. It worked.

Ronald
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing a column and extracting subsets

Please help with this.. my file sizes exceed 40GB,,not possible to do manually. I have a string in the 2nd column that has strings like 5M108N31M, 3S2M100N45M4S etc..the first column is a number. There can be 0,1 or 2 number of S but only 1,2 Ms and only 1 N. S only occurs at the... (4 Replies)
Discussion started by: ritakadm
4 Replies

2. Shell Programming and Scripting

Help with File processing - Extracting the column

I have a line from table space report: 5 135_TT ms Normal 1774336.0 1774208.0 761152.0 1013056.0 57.1% Now I have to get 1013056.0 as o/p. For this I tried cut -f32 -d" " previously it worked now it is showing empty space. Suggest me the best code for this which... (1 Reply)
Discussion started by: karumudi7
1 Replies

3. Shell Programming and Scripting

Extracting rows with a certain column

Hi, I want to extract rows that have specific characters at a certain column. It might be best to show you my problem. So my tab delimited file looks like this: YPR161C 10 16 864445 866418 - Verified 3.558 YOL138C 6 15 61325 65350 - Verified 0.6... (1 Reply)
Discussion started by: phil_heath
1 Replies

4. Shell Programming and Scripting

extracting a column using search term

I am trying to select a column using a search term. My input file looks like this (tab delimited): ABC BJS FDG GHH DGH DFG GHF 95 456 5 266 87 4567 67 3 54 678 4567 45 6 36 232 55 3 5 6 8 34 cat filename | awk '{print $2}'above code will give me the second column. However, what I want... (2 Replies)
Discussion started by: SangLad
2 Replies

5. Shell Programming and Scripting

Extracting column value from perl

Hello Kindly help me to find out the first column from first line of a flat file in perl I/P 9869912|20110830|00000000000013009|130|09|10/15/2010 12:36:22|W860944|N|00 9869912|20110830|00000000000013013|130|13|10/15/2010 12:36:22|W860944|N|00... (5 Replies)
Discussion started by: Pratik4891
5 Replies

6. Shell Programming and Scripting

extracting row with max column value using awk or unix

Hello, BC106081_abc_128240811_128241377 7.96301 BC106081_abc_128240811_128241377 39.322 BC106081_cde_128240811_128241377 1.98628 BC106081_def_128240811_128241377 -2.44492 BC106081_abc_128240811_128241377 69.5504 FLJ00075_xyz_14406_16765 -0.173417 ... (3 Replies)
Discussion started by: Diya123
3 Replies

7. Shell Programming and Scripting

Extracting a column from a file and merging with other file using awk

Hi All: I have following files: File 1: <header> text... text .. text .. text .. <\header> x y z ... File 2: <header> text... text .. text .. (4 Replies)
Discussion started by: mrn006
4 Replies

8. Shell Programming and Scripting

Extracting 3rd column using awk from file with spaces.

BAQ001 /dev/rdsk/c2t0d7 1C13 (M) RW 69053 The line above is from a text file. I want to use awk to extract the value in the third column 1C13. I just can't seem to get the syntax right or something. Any help would be appreciated. Thanks, (5 Replies)
Discussion started by: ricnetman
5 Replies

9. UNIX for Advanced & Expert Users

extracting/copy a column into a new column

Hello, Anybody out there knows how to copy a column data into a blank column using unix command? Thanks (1 Reply)
Discussion started by: folashandy
1 Replies

10. Shell Programming and Scripting

Extracting one column from a ps -ef command

Hi, I want to extract one value/column from a ps -ef command. Here's an example of the output: mqm 14552 1 0 15:48:43 - 0:00 amqpcsea SWNETTQ1 mqm 57082 1 0 15:48:42 - 0:00 amqpcsea SWNETDQ1 mqm 88104 1 0 15:26:37 - 0:00 amqpcsea SWNETEQ1... (6 Replies)
Discussion started by: m223464
6 Replies
Login or Register to Ask a Question