So I have a file with a number of records that look like the following:
Peugeot:206:2000:Red:1
And I'm trying to grep search for any that contain a year 1995-1999. I have tried
grep '[1995-1999]' file.txt
to no avail. Any ideas? Thanks.
So I have a file with a number of records that look like the following:
Peugeot:206:2000:Red:1
And I'm trying to grep search for any that contain a year 1995-1999. I have tried
grep '[1995-1999]' file.txt
to no avail. Any ideas? Thanks.
This one is easy:
grep -E "199[5-9]"
does the job. It is easy, because the intended number range matches a character code range. For a more complicated example, e.g., 1998-2003, you will have to split the range appropriately:
grep -E "199[8-9]|200[0-3]"
grep -E '199[5-9]' file.txt
do it? – clement Nov 19 '15 at 16:35egrep "199[5-9]" file.txt
– lese Nov 19 '15 at 16:39