grep for greater than 12 chars


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep for greater than 12 chars
# 1  
Old 04-27-2009
grep for greater than 12 chars

Hi, is there any way in grep to grep for a certain number of characters? For example I have a list of customerIDs, I want to grep for all greater than 12 characters?
# 2  
Old 04-27-2009
I assume the customer number is really a number, constructed from digits 0-9, yes?

If so, try the following regexp:

Code:
grep '[0-9]\{13\}' /path/to/file

This will find all lines containing a sequence of 13 or more digits.

I hope this helps.

bakunin
# 3  
Old 04-27-2009
thanks for that, i found two other ways

Code:
awk ' ( length($0) >5 )  {print } '

and

Code:
egrep ".{6}" file.txt > new.file.txt


Last edited by Yogesh Sawant; 04-27-2009 at 02:58 PM.. Reason: added code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies

2. UNIX for Dummies Questions & Answers

Grep or sed to search, replace/insert chars!

HI All Im trying to come up with an approach to finding a string, using a portion of that string to insert it on lines starting with the value "GOTO" appending to end of line after removing PT's ( See example below! ) EXAMPLE: 1. I would like to search for the line that starts with "TLAXIS/"... (7 Replies)
Discussion started by: graymj
7 Replies

3. UNIX for Dummies Questions & Answers

Grep SQL output file for greater than number.

Hi, This is my first post. I have a korn shell script which outputs a select statment to a file. There is only one column and one row which contains a record count of the select statement. The select statement looks something like this: SELECT COUNT(some_field) AS "count_value" ... (2 Replies)
Discussion started by: MurdocUK
2 Replies

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

5. Shell Programming and Scripting

How to grep a pattern having value greater than 123 in a file?

Hi, I have a dynamically growing ascii file which has large data (both text and digits). I need to grep those lines having value greater than '123'. These numeric values may appear at anywhere in the line, hence I could not use awk to split to columns. So, please help me with the grep regular... (12 Replies)
Discussion started by: royalibrahim
12 Replies

6. Shell Programming and Scripting

grep /target greater than time period??

Hey guys, I'm fairly new at unix shell scripting and I have a quick question. Quick overview I devolped a script where I generate a file ..and I want to grep any time greater than 30 minutes. What i do is runa command to generates the below and puts it into a file: I run ./ggsci << endit... (4 Replies)
Discussion started by: nomiezvr4
4 Replies

7. Shell Programming and Scripting

Need to Grep or awk a logfile for greater than value

Hello all Hoping someone would be kind enough to suggest a solution to a problem i have, and see if maybe i can even do this without a script. Essentially i have a very large log file, and within it each line had a value called TTMT, and it records a variable number in the following way, so... (6 Replies)
Discussion started by: 1905
6 Replies

8. Shell Programming and Scripting

Grep a file excluding row with some chars

Hello all, I've a file (Java Garbage Collector) with the following rows inside it: ........ ........ 13.853: 13.992: 14.050: 14.193: 14.282: 14.355: 14.465: 14.579: 14.585: 14.891: 15.529: ........ ........ (12 Replies)
Discussion started by: Lord Spectre
12 Replies

9. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

10. Shell Programming and Scripting

How to convert C source from 8bit chars to 16bit chars?

I was using the following bash command inside the emacs compile command to search C++ source code: grep -inr --include='*.h' --include='*.cpp' '"' * | sed "/include/d" | sed "/_T/d" | sed '/^ *\/\//d' | sed '/extern/d' Emacs will then position me in the correct file and at the correct line... (0 Replies)
Discussion started by: siegfried
0 Replies
Login or Register to Ask a Question