Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Grep a line with between 3 and 5 digits Post 302136372 by ceemh3 on Monday 17th of September 2007 10:39:24 AM
Old 09-17-2007
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 '\<[0-9]\{3,5\}\>' test.txt
or
grep '[0-9]\{3,5\}' test.txt
or
egrep '[0-9]{3,5}' test.txt

I would appreciate any help that anyone can give me

thanks

Last edited by ceemh3; 09-17-2007 at 11:58 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

locate special characters and digits using grep

Hello, i have a file called test hello1 "how" are you4 good"bye" good7bye i am trying to print all lines from test that either end with a digit or contain a double quote character anywhere on the line. i did grep -n '$' test and was able to print lines ending with digits. i also did... (2 Replies)
Discussion started by: hobiwhenuknowme
2 Replies

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

3. UNIX for Dummies Questions & Answers

how to use grep: finding a string with double quotes and multiple digits

I have a file with a lot of lines (a lot!) that contain 10 digits between double quotes. ie "1726937489". The digits are random throughout, but always contain ten digits. I can not for the life of me, (via scouring the internet and grep how-to manuals) figure out how to find this when I search.... (3 Replies)
Discussion started by: titusbass
3 Replies

4. Shell Programming and Scripting

Find filenames with three digits and add zeros to make five digits

Hello all! I've looked all over the internet and this site and have come up a loss with an easy way to make a bash script to do what I want to do. I have a file with a naming convention as follows: 2012-01-18 string of words here 123.jpg 2012-01-18 string of words here 1234.jpg 2012-01-18... (2 Replies)
Discussion started by: Buzzman25
2 Replies

5. Shell Programming and Scripting

Listing all digits behind the comma with grep

Hello, Unix-Forums! 1.23456789 This an example number. It can be any number. I want grep to only find the digits behind the "." That means 23456789 should be the output in this case. How would I do that? (2 Replies)
Discussion started by: intelinside
2 Replies

6. UNIX for Dummies Questions & Answers

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. grep -i '\<\{3,4,5\}\>' file ---------- Post updated at 05:58 PM ---------- Previous update was at 05:41... (1 Reply)
Discussion started by: jimmyf
1 Replies

7. Shell Programming and Scripting

Bash detecting number of digits in line

Hi I have a problem, I am attempting to write a bash script that goes through a file and can determine how many characters are at a set point in a line starting with QTY+113:100:PCE, If it detects 3 digits (number in bold) then pad it out with 12 zero's If there are only two digits then pad it... (8 Replies)
Discussion started by: firefox2k2
8 Replies

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

9. UNIX for Beginners Questions & Answers

sed / awk script to delete the two digits from first 3 digits

Hi All , I am having an input file as stated below 5728 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r03_q_reg_20_/Q 011 611 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r04_q_reg_20_/Q 011 3486... (4 Replies)
Discussion started by: kshitij
4 Replies
ZGREP(1)						    BSD General Commands Manual 						  ZGREP(1)

NAME
zgrep, zegrep, zfgrep -- print lines matching a pattern in gzip-compressed files SYNOPSIS
zgrep [grep-flags] [--] pattern [files ...] zegrep [grep-flags] [--] pattern [file ...] zfgrep [grep-flags] [--] pattern [file ...] DESCRIPTION
zgrep runs grep(1) on files or stdin, if no files argument is given, after decompressing them with zcat(1). The grep-flags and pattern arguments are passed on to grep(1). If an -e flag is found in the grep-flags, zgrep will not look for a pattern argument. zegrep calls egrep(1), while zfgrep calls fgrep(1). EXIT STATUS
In case of missing arguments or missing pattern, 1 will be returned, otherwise 0. SEE ALSO
egrep(1), fgrep(1), grep(1), gzip(1), zcat(1) AUTHORS
Thomas Klausner <wiz@NetBSD.org> BSD
December 28, 2003 BSD
All times are GMT -4. The time now is 11:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy