troubleshooting Question

Delete lines from long file UNLESS the line starts with specified character (linux)

Avatar of hankknight
hankknightFlag for Canada asked on
Linux
12 Comments7 Solutions210 ViewsLast Modified:
Hello,

I have a file that is more than 800 mb (it is a .sql dump saved in UTF-8).

It has useful information but also allot of junk.

Most of the lines that I do NOT need start with funny characters like this:

ÂÈÒØÙæçè÷øÿ

So I want to REMOVE all lines UNLESS they start with one of the following:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"`\/-#$*()

Lines may ALSO begin with a space or a tab.

If a line starts with ANYTHING else then I want the entire line DELETED.

How can I do this with a .sh script?

Thanks!
ASKER CERTIFIED SOLUTION
Kent Olsen
Data Warehouse / Database Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 7 Answers and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 7 Answers and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros