Skip to content

Instantly share code, notes, and snippets.

@devdrops
Created October 18, 2016 15:49
Show Gist options
  • Select an option

  • Save devdrops/b68ebf70c197a8d72956f486a2543e6f to your computer and use it in GitHub Desktop.

Select an option

Save devdrops/b68ebf70c197a8d72956f486a2543e6f to your computer and use it in GitHub Desktop.
grep: limit char length

grep: limit char length

From http://stackoverflow.com/a/10489580

  • Match the first 18 chars from a given string potato on file foo.txt

    egrep -Rso 'potato".{0,18}' foo.txt
    
  • Match the previous 10 and next 10 chars:

    egrep -Rso '.{0,10}potato".{0,10}' foo.txt
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment