Sponsored Content
Full Discussion: Grep by column number
Top Forums UNIX for Dummies Questions & Answers Grep by column number Post 302283101 by awk on Monday 2nd of February 2009 02:26:11 PM
Old 02-02-2009
Quote:
Originally Posted by hitman247m
I have a data file that is arranged like this:

Code:
Marketing  Ranjit Singh   Eagles       Dean Johnson   FULL
Marketing  Ken Whillans   Eagles       Karen Thompson FULL
Sales      Peter RobertsonGolden TigersRich Gardener  PART
President  Sandeep Jain   Wimps        Ken Whillans   CONT
Operations John Thompson  Hawks        Cher           PART
Operations Cher           Vegans       Karen Patel    CONT
Sales      John Jacobs    Hawks        Davinder Singh FULL
Finance    Dean Johnson   Vegans       Sandeep Jain   FULL
EngineeringKaren Thompson Vegans       John Thompson  PART
IT         Rich Gardener  Golden TigersPeter RobertsonFULL
IT         Karen Patel    Wimps        Ranjit Singh   FULL

I need to be able to search within characters 12-26 only. But I also want it to output the entire line, like the basic grep function does.

I've been working on it for a week, and I haven't been able to get grep to recognize that I want the first 11 characters, and everything after the 26th character.

Please help Smilie
Code:
grep -E "^.{11}Peter Robertson" file
Sales      Peter RobertsonGolden TigersRich Gardener  PART

Make sure those are spaces and not tabs between the records. The grep is based on it being spaces, basically saying from the start of the line, take anything in the first 11 characters, and then start the comparison.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

returning a column number

Hi all, i was doing a small program where if i was to be given the first 3 letters of any month i.e. in the form of Jan or Apr then it would return the column number where it finds a match. To do this i created a 12 element array of months with first 3 letters and if i echo'ed the contents of... (2 Replies)
Discussion started by: scriptingmani
2 Replies

2. Shell Programming and Scripting

Identifying the column number

I'd like to be able to identify in which column a string occurs. So far I know that I can tell how many columns there are and how to return a specific column: $ sar -r | grep 'kbswpcad' | awk 'NF = 9 { print $NF }' %swpused I've even managed to get the columns to output to an array but I... (2 Replies)
Discussion started by: pondlife
2 Replies

3. Shell Programming and Scripting

Grep lines for number greater than given number

Hello, I am newbie to bash scripting. Could someone help me with the following. I have log file with output as shown below **************************LOG************************* 11/20/2013 9:11:23.64 Pinging xx.xx.xx.xx with 32 bytes of data: 11/20/2013 9:11:23.64 Reply from xx.xx.xx.xx:... (4 Replies)
Discussion started by: meena_2013
4 Replies

4. Shell Programming and Scripting

How to awk or grep the last column in file when date on column contains spaces?

Hi have a large spreadsheet which has 4 columns APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96034 Storage Mgmt Team APM00111803814 server_2 96152 GWP... (6 Replies)
Discussion started by: kieranfoley
6 Replies

5. Shell Programming and Scripting

Help with compare two column and print out column with smallest number

Input file : 5 20 500 2 20 41 41 0 23 1 Desired output : 5 2 20 0 1 By comparing column 1 and 2 in each line, I hope can print out the column with smallest number. I did try the following code, but it don't look good :( (2 Replies)
Discussion started by: perl_beginner
2 Replies

6. Shell Programming and Scripting

Split column data if the table has n number of column's

please write a shell script Table -------------------------- 1 2 3 a b c 3 4 5 c d e 7 8 9 f g h Output should be like this --------------- 1 2 3 3 4 5 7 8 9 a b c c d e f g h (1 Reply)
Discussion started by: Priti2277
1 Replies

7. Shell Programming and Scripting

Split column data if the table has n number of column's with some record

Split column data if the table has n number of column's with some record then how to split n number of colmn's line by line with records Table --------- Col1 col2 col3 col4 ....................col20 1 2 3 4 .................... 20 a b c d .................... v ... (11 Replies)
Discussion started by: Priti2277
11 Replies

8. UNIX for Beginners Questions & Answers

Grep A Column Based On Column Name

I have a file with two columns separated by white space. Dog Cat fido sneaky dopey poptart ears whisker barky herd Trying to list the words under the column named Dog. Tried a few variations of awk but can't... (4 Replies)
Discussion started by: jimmyf
4 Replies

9. Shell Programming and Scripting

Extract number from column

I have a lot of file with a lot of lines following the same pattern the lines go like this: alpha_9/output- -413.74928476 2.6116 and I want it to be: 9 -413.74928476 2.6116 thanks for the help (5 Replies)
Discussion started by: galboski
5 Replies

10. Shell Programming and Scripting

Grep values from column 2 in reference of column 1

Gents Is it possible to update the code to get the desired output files from the input list. I called variable to the first column. I need to consider the first column as key to grep the values in the second column according to the desired request. input list (attached ) output1 ... (12 Replies)
Discussion started by: jiam912
12 Replies
Graphics::Primitive::Insets(3pm)			User Contributed Perl Documentation			  Graphics::Primitive::Insets(3pm)

NAME
Graphics::Primitive::Insets - Space between things DESCRIPTION
Graphics::Primitive::Insets represents the amount of space that surrounds something. This object can be used to represent either padding or margins (in the CSS sense, one being inside the bounding box, the other being outside) SYNOPSIS
use Graphics::Primitive::Insets; my $insets = Graphics::Primitive::Insets->new({ top => 5, bottom => 5, left => 5, right => 5 }); METHODS
Constructor new Creates a new Graphics::Primitive::Insets. Instance Methods as_array Return these insets as an array in the form of top, right, bottom and left. bottom Set/Get the inset from the bottom. equal_to Determine if these Insets are equal to another. left Set/Get the inset from the left. right Set/Get the inset from the right. top Set/Get the inset from the top. zero Sets all the insets (top, left, bottom, right) to 0. AUTHOR
Cory Watson, "<gphat@cpan.org>" SEE ALSO
perl(1) COPYRIGHT &; LICENSE Copyright 2008-2010 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-08-21 Graphics::Primitive::Insets(3pm)
All times are GMT -4. The time now is 06:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy