Results 1 to 2 of 2
Hi everyone,
This is my first posting to the forum. I hope you can help me with this.
I have a file called "donors.dat" that I am trying to display ...
- 10-08-2011 #1Just Joined!
- Join Date
- Oct 2011
- Posts
- 1
Using grep to search and display specific columns
Hi everyone,
This is my first posting to the forum. I hope you can help me with this.
I have a file called "donors.dat" that I am trying to display from the last 5 columns (which is a zip code) only the ones that have a 2,3,4,5, and 7. Here is the first line:
01 e smith edward 11 012 33308
I tried this, but it didn't work:
grep '[2-57]$....' donors.dat
What am I doing wrong?
- 10-08-2011 #2Linux User
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 262
Since you have the "$" in the regular expression, the last digit on the line must be in the set [ 2,3,4,5,7 ] and the .... would mean the next line has at least 4 characters.
Have you tried looking for a much more complex regular expression? Such as:
Code:'.* .* .* .* .* .* .*[2-57].*$'


Reply With Quote