![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
"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
|
|||
|
|||
|
Thank you!!! This is perfect.
|
|||
| Google The UNIX and Linux Forums |