Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Grep lines with numbers greater than 2 digits at the end of the line Post 302770238 by Don Cragun on Friday 15th of February 2013 01:37:30 AM
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}$'

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
CheckDigits::M11_013(3pm)				User Contributed Perl Documentation				 CheckDigits::M11_013(3pm)

NAME
CheckDigits::M11_013 - compute check digits for VAT Registration Number (GR) SYNOPSIS
use Algorithm::CheckDigits; $ustid = CheckDigits('ustid_gr'); if ($ustid->is_valid('123456783')) { # do something } $cn = $ustid->complete('12345678'); # $cn = '123456783' $cd = $ustid->checkdigit('123456783'); # $cd = '3' $bn = $ustid->basenumber('123456783'); # $bn = '12345678'; DESCRIPTION
ALGORITHM 1. Beginning right with the digit before the checkdigit all digits are weighted with 2 ** position. I. e. the last digit is multiplied with 2, the next with 4, then 8 and so on. 2. The weighted digits are added. 3. The sum from step 2 is taken modulo 11. 4. If the sum from step 3 is greater than 9, the check sum is 0 else it is the sum itself. METHODS is_valid($number) Returns true only if $number consists solely of numbers and hyphens and the two digits in the middle are valid check digits according to the algorithm given above. Returns false otherwise, complete($number) The check digit for $number is computed and inserted into the middle of $number. Returns the complete number with check digit or '' if $number does not consist solely of digits, hyphens and spaces. basenumber($number) Returns the basenumber of $number if $number has a valid check digit. Return '' otherwise. checkdigit($number) Returns the check digits of $number if $number has valid check digits. Return '' otherwise. EXPORT None by default. AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de> SEE ALSO
perl, CheckDigits, www.pruefziffernberechnung.de, perl v5.10.0 2008-05-17 CheckDigits::M11_013(3pm)
All times are GMT -4. The time now is 09:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy