The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-10-2006
Registered User
 

Join Date: Sep 2005
Posts: 15
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.
Reply With Quote
Forum Sponsor
  #2  
Old 01-10-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
There are many ways that this can be done; here's one using awk.

Code:
awk '$2 ~ /your pattern/' yourdata
change $2 to whatever field you need.
Reply With Quote
  #3  
Old 01-10-2006
Registered User
 

Join Date: Sep 2005
Posts: 15
I don't have a pattern. I am trying to list out a specific position.
Reply With Quote
  #4  
Old 01-10-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
Homework perhaps?

awk '{print $2}' your data
Reply With Quote
  #5  
Old 01-10-2006
Registered User
 

Join Date: Sep 2005
Posts: 15
That worked. Thanks for your help.
Reply With Quote
  #6  
Old 09-20-2008
Registered User
 

Join Date: Sep 2008
Posts: 14
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.
Reply With Quote
  #7  
Old 09-20-2008
vidyadhar85's Avatar
The Tutor
 

Join Date: Jun 2008
Location: INDIA
Posts: 537
if you just wanna know whats at position 10,26 and so on.. you can go for awk and use
Quote:
substr function
go through the man page of awk...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0