I have several very large text files (over 1 gb total) that I want to strip out any line that has a specific string, and place that entire line in a text file. Best case it would open every file in the directory. Thanks for any pointers (existing websites?)
Related Blogs
- IE Input Text Width « Webmasters.am Blog
- VMware Disks Moving Back To .DSK File Name Format » boche.net …
- Web Directory Submission – Ramping Up Link Count | Article Buster
- Urban Zip-Line Coming to San Francisco! Zoom 600 Feet Over Justin …
- Is QVC a good place to shop for gifts and gadgets? | 24/7 Online …
- Renewable Energy Stocks Directory Update at InvestorIdeas.com …
- [RS] Melrose.Place.2009.S01E16.HDTV.XviD-LOL Rapidshare …
- Twitter Chats: A Great Place For Your Brand To Shine | Personal …
- Latest Line Of Credit Auctions | Little Of Life
- Motorola H17txt Bluetooth Headset Offers Text to Speech
- Handbag Trends For Spring 2008 Fashion Directory | Fashion Trends
- Sense of Place and Knowing Where We're From
- Active Directory Password Management in Windows 2003 | WebsHost.net
- Appeals-Court Ruling Favors eBay in Tiffany Case | Chad Bray …
- Nancy Pelosi's Jobs Chart, Updated | The Plum Line
- Senator Corker: Of Course Repeal Can Happen! (If Republican Is …
- April 1: YouTube Offers New Text-Only Format | Peter Kafka …
- B-line | Design Milk
- Second string getting chance to shine | Daily Trojan
- Better Place blog | Electric vehicles and the transition to …













a quicker way than using Perl would be to use grep…if you have access to it. It will be on your system if you are using Linux or Unix and is available in Cygwin if you are using windows. Try this:
grep -h YOUR_KEYWORD_HERE *.txt > results.txt
if you MUST use Perl, the absolute best programming language in the world IMHO, try this:
——–cut——–
# this is so we can use English shortcuts like $ARG and such
use English;
# open a file to store the results
open (OUTPUT, ">results.txt") || die ("Could not open file results.txt; $OS_ERROR");
# read each input file from the command line
# i.e. perl keyword.pl file1.txt file2.txt …
while (<>) {
# if the line has the keyword, print it to the output file
if ($ARG =~ /YOUR_KEYWORD_HERE/) {
print OUTPUT $ARG;
warn "Found YOUR_KEYWORD_HERE in $ARGV\n";
}
}
# close the output file
close (OUTPUT);
——–cut——–
I’ll leave it as an exercise for you to figure out which one is faster when dealing with files larger than 1 MB or so. Also, you might want to do both and then diff the results to see any differences between the two.