Grep lines with numbers greater than 2 digits at the end of the line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep lines with numbers greater than 2 digits at the end of the line
# 1  
Old 02-14-2013
Grep lines with numbers greater than 2 digits at the end of the line

I'm trying to grep lines where the digits at the end of each line are greater than digits. Tried this but it will only allow me to specify 2 digits. Any ideas would greatly be appreciated.
Code:
 grep -i '\<[0-9]\{3,4,5\}\>' file

---------- Post updated at 05:58 PM ---------- Previous update was at 05:41 PM ----------

OK, I got it, this works
Code:
grep '[0-9]..'$

# 2  
Old 02-15-2013
Quote:
Originally Posted by jimmyf
I'm trying to grep lines where the digits at the end of each line are greater than digits. Tried this but it will only allow me to specify 2 digits. Any ideas would greatly be appreciated.
Code:
 grep -i '\<[0-9]\{3,4,5\}\>' file

---------- Post updated at 05:58 PM ---------- Previous update was at 05:41 PM ----------

OK, I got it, this works
Code:
grep '[0-9]..'$

Code:
grep '[0-9]..'$

will match a digit followed by any two characters at the end of a line. If what you want is three digits at the end of a line, try:
Code:
grep '[0-9][0-9][0-9]$'

or
Code:
grep -E '[0-9]{3}$'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Put in one line only the lines with digits

Hello, I haven't been here for a while and I might be forgetting some things. I have an input text like this titleA http://myurl/bla/blabla/1234 http://myurl/bla/blabla/6789 titleB http://myurl/bla/blabla/5678 http://myurl/bla/blabla/1234 titleC http://myurl/bla/blabla/9123... (10 Replies)
Discussion started by: Kibou
10 Replies

2. UNIX for Advanced & Expert Users

Grep for a line containing only 5 numbers

How would you grep for a line containing only 5 numbers? Something like this. 10 2 12 1 13 (4 Replies)
Discussion started by: cokedude
4 Replies

3. Shell Programming and Scripting

Grep username and get all the lines with thread numbers

I need help to extract the file. If I am entering the user name like abcd@xyz.com, search the username and get the tread number. Once will get thread number all the line having same threadnumber wanted to keep in seperate file. It can be more than thread number for single username. For... (3 Replies)
Discussion started by: nes
3 Replies

4. UNIX for Dummies Questions & Answers

grep quoted numbers from lines

I want to parse the lines and want to extract the double quoted numbers as: "SQL3149N "72" rows were processed from the input file. "0" rows were successfully inserted into the table. "0" rows were rejected." and want the output in 3 variables like a=72 b=0 c=0 thanks in advance ... (3 Replies)
Discussion started by: mahesh_191
3 Replies

5. Programming

concatinate all lines from second line to end of line in perl

I have datafile like ~dta.yunm shhshsgggssssjsksjs sggsjshsjsjssss shshshhshshshs i wish to take only first line and all other lines in concatenated form in second line what should I do??? output like ~dta.yunm shhshsgggssssjsksjssggsjshsjsjssssshshshhshshshs please tell me how... (7 Replies)
Discussion started by: sujit_singh
7 Replies

6. Shell Programming and Scripting

Adding patterns with increasing numbers at the end of every line

Hi All, I have a file which has some Linux commands in every line like more 456.dat more 3232.dat more 433.dat I want to add texts like this at the end of every line: more 456.dat > 1.txt more 3232.dat > 2.txt more 433.dat > 3.txt So, that the result of more goes into 1.txt... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. UNIX Desktop Questions & Answers

matching 3 digits at the begining and the end of the line

I have a file with hundreds of records and I need to find those records that have three digits at the beginning and the same three digits at the end. $GREP '\(\)\(\)\(\)\3\2\1'I believe this is part of the script but I am not sure how to compare these 3 digits with the 3 digits at the end of... (2 Replies)
Discussion started by: bartsimpsong
2 Replies

8. UNIX for Advanced & Expert Users

Add line numbers to end of each line

Hi i would like to add line numbers to end of each line in a file. I am able to do it in the front of each line using sed, but not able to add at the end of the file. Can anyone suggest The following code adds line number to start of each line sed = filename | sed 'N;s/\n/\t/' how can i... (5 Replies)
Discussion started by: rudoraj
5 Replies

9. Solaris

Need help capturing end of line numbers

Hello All, Currently I am attempting to write a script which will capture a number at the end of a line. The line which I am searching through ends as follows: word word=number for example word word=3 OR word word=15 I am stuck on how to capture whatever is to the right... (3 Replies)
Discussion started by: icalderus
3 Replies

10. UNIX for Dummies Questions & Answers

Grep a line with between 3 and 5 digits

Hi, I am having problems using grep to extract only 3,4 or 5 digit numbers from a text file, using: grep '\<\{3,5\}\>' test.txt or grep '\{3,5\}' test.txt or egrep '{3,5}' test.txt I would appreciate any help that anyone can give me thanks (1 Reply)
Discussion started by: ceemh3
1 Replies
Login or Register to Ask a Question