Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old Jan 23, 2013, 08:24 PM   #1
Big Dave
macrumors 6502
 
Join Date: Nov 2007
Location: Crestview, Fl
grep syntax help

Let's say I have a file that contains ordered pairs of data.
Example..
-10 -10
-10 -9
...
10 9
10 10

If I want to grep out a portion of this file, say from -5 -5 to 5 5, I would use grep but I am returning extra data such as -5 6 which is outside of my search. Here is the code I have but I could use some help with my grep term.

Code:
#!/bin/bash
for ((x=-5; x<=5; x++))
  do
   for ((y=-5; y<=5; y++))
     do
      grep -- "$x $y" file
     done
  done
Has anyone seen a problem like this before?
Thanks.

Last edited by Big Dave; Jan 23, 2013 at 08:25 PM. Reason: error
Big Dave is offline   0 Reply With Quote

 
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:38 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC