The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Split large file and add header and footer to each file ashish4422 Shell Programming and Scripting 1 04-15-2008 03:12 AM
File too large macgre_r HP-UX 7 03-13-2008 11:15 PM
Using TAR on a large file hshapiro UNIX for Dummies Questions & Answers 4 09-28-2006 06:30 AM
Strange difference in file size when copying LARGE file.. 0ktalmagik Filesystems, Disks and Memory 1 06-03-2006 04:34 PM
large file in AIX 4.3 alzenir Filesystems, Disks and Memory 1 12-08-2005 12:03 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-18-2003
Registered User
 

Join Date: Sep 2001
Location: Phoenix
Posts: 76
Large file search

How do I search through a file that is so large (over 1GB) and find out exactly on what the exact pattern is found. I've used grep and know the line exist but what it returns is not complete because there are blobs in the data and there are control characters, etc and part of the data may beyond 2048 characters limit in vi...

If I can figure out exactly what line number the pattern is found in this large file I can at least attempt to do a head|tail|more combinations or split it correctly...

I'd like to find it using vi editor but the file's too large..

Thanks.
Gian
Forum Sponsor
  #2  
Old 08-18-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
"blobs in the data" .... I don't believe that I've encountered that particular complaint before. But I can help with the rest.

grep has a -n option to print line numbers. But you really should switch to sed. sed can process data rather quickly. It can handle large files well. And it has plenty of power. Here are a few examples:

sed -n '/<pattern>/p' < datafile
sed -n '/<pattern>/=' < datafile
sed -n /<pattern>/{ =;p;}' < datafile
sed -n 25p < datafile
sed -n 25,30p < datafile

The first one displays the lines that match the pattern.
The second displays the line numbers of the matches.
The third one does both, using a single pass though the file.
Then we print line 25, then lines 25 through 30.

And you can use the l command (letter l) instead of the p command. The l command will render the line readable if it has special characters or is very long.
  #3  
Old 08-20-2003
Registered User
 

Join Date: Sep 2001
Location: Phoenix
Posts: 76
Thank you!!! This is perfect.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0