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

Similar Threads
thread Thread Starter Forum Replies Last Post
Help with TextWrangler GREP? JacobJones Mac Applications and Mac App Store 1 Jun 13, 2013 06:40 AM
Syntax Coloring Gone. . . ahan.tm iPhone/iPad Programming 9 Dec 4, 2012 03:44 AM
Help with Void Syntax tulipano Mac Programming 15 Jul 11, 2012 06:27 AM
Objective C Syntax nashyo iPhone/iPad Programming 6 Jul 4, 2012 11:56 AM
popen call to grep farmerdoug Mac Programming 7 Jun 12, 2012 01:37 PM

Forum Jump

All times are GMT -5. The time now is 02:08 AM.

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

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