match pattern in a big file

Have a big text file (>2G). Want to get the lines, in which there is a pattern match, saying pattern  'ABC  XYZ'. The line length can be up to 4000 characters. Questions:
what computer language is suitable for this situation? Could any gurus please share a piece of code or a link about it?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sed -n "/ABC  XYZ/p"
There's a difference between a pattern match and string search for a fixed string.

The latter is better handled using a Boyer-Moore approach. Many programming languages have regular expression support to search for patterns as well as primitives to match fixed strings.

Perl is indifferent to file size or line length, so as an example you could do

perl -ne 'print if index($_, "ABC XYZ") >= 1' BigTextFile.txt

Open in new window

and it will print out just those lines that contain the string of interest.
I didn't reach for sed because I remembered that it "silently" truncated lines that were longer than a certain size. That's apparently no longer true for modern implementations of sed, but is a caution if you're dealing with a really old system.
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

I had forgotten that sed could have that problem. Thank you for the precaution.
I might have used grep for this task, but it would be hard to call that a programming language.  
(Though I guess it could qualify as a "computer language")
In perl, I might prefer
perl -ne 'print if index($_, "ABC XYZ") >= 0' BigTextFile.txt
perl -ne 'print if /ABC XYZ/' BigTextFile.txt
Yes, greater than or equal to zero. What was I thinking?

(The original grep had a similar line length restriction.)
jl66ConsultantAuthor Commented:
Thanks a lot for the info.

I ran it in windows 7 and got the error. The text I tried to catch in the big file is "text" such as
...,"text":"RT @...

F:\>perl -ne 'print if /text/' bigtext.txt
Can't find string terminator "'" anywhere before EOF at -e line 1.

F:\>perl -ne 'print if index($_, "text") >= 0' twitter_short.txt
Can't find string terminator "'" anywhere before EOF at -e line 1.

The perl version is
F:\>perl -version
This is perl 5, version 14, subversion 4 (v5.14.4) built for MSWin32-x64-multi-thread
Copyright 1987-2013, Larry Wall

I don't know why?
MSWin uses different quotes
perl -ne "print if index($_, 'text') >= 0" twitter_short.txt

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jl66ConsultantAuthor Commented:
Thanks a lot. Big help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.