![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep command | christine33990 | UNIX for Dummies Questions & Answers | 11 | 05-05-2008 11:45 PM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-04-2007 11:59 PM |
| grep command help | ishmael^soyuz | Shell Programming and Scripting | 4 | 07-11-2007 06:01 AM |
| grep command | pmsuper | UNIX for Dummies Questions & Answers | 6 | 11-22-2006 04:12 AM |
| grep command | debasis.mishra | Shell Programming and Scripting | 1 | 03-27-2006 10:53 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Grep command
I have 2 lines of data:
1. AAAAA 12345 55555 2. BBBBB 33333 88888 I want to be able to grep a position in line 1. For example, lets say the 12345 in line 1 are in positions 7-11. Can I grep positions 7-11 of line 1? If so, how do I do this? These will change every day so I need to grep a position and not a specific range of numbers. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
There are many ways that this can be done; here's one using awk.
Code:
awk '$2 ~ /your pattern/' yourdata |
|
#3
|
|||
|
|||
|
I don't have a pattern. I am trying to list out a specific position.
|
|
#4
|
|||
|
|||
|
Homework perhaps?
awk '{print $2}' your data |
|
#5
|
|||
|
|||
|
That worked. Thanks for your help.
|
|
#6
|
|||
|
|||
|
get specific position in line
Hey,
I really want to grep some specific positions in a line of letters. E.g. I need to know what's on position 10, 26 and 78. I've tried some of the hints posted but nothing seem to work and my brain is fried.. Anyone with an easy way of solving this? Thanks A LOT! format of text: >1A6A.B PRFLEYSTSECHFFNGTERVRYLDRYFHNQEENVRFDSDVGEFRAVTELGRPDAEYWNSQKDLLEQKRGRVDNYCRHNYG VVESFTVQRRVHPKVTVYPSKTQPLQHHNLLVCSVSGFYPGSIEVRWFRNGQEEKTGVVSTGLIHNGDWTFQTLVMLETV PRSGEVYTCQVEHPSVTSPLTVEWRAR Though I can cut out the lines with the idenfication '>1A6A.b' if it simplifies things. |
|
#7
|
||||
|
||||
|
if you just wanna know whats at position 10,26 and so on.. you can go for awk and use
Quote:
|
||||
| Google The UNIX and Linux Forums |