how to grep from specific field

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to grep from specific field
# 1  
how to grep from specific field

the file has several date fields.for example, #2, #3,and #5 are date fields.
I want grep year '2002' just within #2 field and get all the rows which content year '2002' in the #2 field. is it possible to do this? how to do it? Thanks
# 2  
Welcome to the forums ! Smilie

You could have searched the forums for 'n' number of answers.

awk '$2 ~ 2002' filename

# 3  
MySQL Thank you muck

Thanks a lot for the prompt reply, i'll try the command

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #698
Difficulty: Medium
"Homesteading the Noosphere" (abbreviated HtN) is an essay written by Eric S. Raymond about the social workings of proprietary, corporate software development.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find the difference in specific field

Hi All, Seeking for your assistance to get the difference of field1 and field2 and output all the records if there's a difference. please see below scenario. file1.txt 250|UPTREND FASHION DESIGN,CORP.|2016-04-04 09:36:13.991257 74|MAINSTREAM BUSINESS INC.|2016-04-04 09:36:13.991257... (1 Reply)
Discussion started by: znesotomayor
1 Replies

2. Shell Programming and Scripting

Extract Specific Information from a particular field

Hi, I am trying to extract a specific information from a file which contains more than 200 million records. Attached the input file for your reference. My file contains information below ... (4 Replies)
Discussion started by: rramkrishnas
4 Replies

3. Shell Programming and Scripting

Add value in specific field

Gents, I have many files to change increasing 40000 in specific field. Can you help me with a command with sed or awk to fix this problem. Where the the field has Marker FDU. I need to add 40000 plus example Marker FDU 27152.00 Marker FDU 67152.00 I should... (4 Replies)
Discussion started by: jiam912
4 Replies

4. Shell Programming and Scripting

How to print with awk specific field different from specific character?

Hello, i need help with awk. I have this file: cat number DirB port 67 er_enc_out 0 er_bad_os 0 DirB port 71 er_enc_out 56 er_bad_os 0 DirB port 74 er_enc_out 0 er_bad_os 0 DirB port 75 ... (4 Replies)
Discussion started by: elilmal
4 Replies

5. Shell Programming and Scripting

Get last field specific record

i have file A as below contents --------------------------- Use descriptive thread titles when posting. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". For example, do not post questions For example, do not deliminated. output file as below:... (2 Replies)
Discussion started by: ANSHUMAN1983
2 Replies

6. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

7. Shell Programming and Scripting

Using awk to read a specific line and a specific field on that line.

Say the input was as follows: Brat 20 x 1000 32rf Pour 15 p 1621 05pr Dart 10 z 1111 22xx My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour" I currently have this line but it is... (6 Replies)
Discussion started by: Bungkai
6 Replies

8. Shell Programming and Scripting

Help with grep at specific field of a file

hi, I would like to search for a specific string at a specific line in a file and would like to know the count of it. eg: samp.txt ABC 1234 BELL HNZ 4567 RING NNN 5673 BELL Please help with the command to find the count of BELL in the above file samp.txt at the specific line 10 with... (7 Replies)
Discussion started by: techmoris
7 Replies

9. Shell Programming and Scripting

Removing parts of a specific field

All, I have a field in a comma seperated file with hundreds of lines and about 20 columns and I wish to remove all numbers after the decimal point in field 4 on each line and output the rest to another file or write it back to itself. File is like this 20070126, 123.0, GBP, 1234.5678,... (9 Replies)
Discussion started by: kieranh
9 Replies

10. UNIX for Dummies Questions & Answers

Grep for NULL for a specific field in a unix file

hii.. I have a pipe delimited file For ex: TEST_1-8J6TZN|ASLANK|BHR-09||TRAM I want to grep for NULL in the 4th field only from the above file Please suggest Also let me know if there is any limitation in the suggested command Thanks all in advance..!! (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

Featured Tech Videos