Cut Lines using grep

Hi,

I have a SQL script with "create table" and "alter table" statements and I want to cut all the alter table statements from original file (A) and move it to a different file (B).

Can you please me the option. Thanks a lot for your time.

# Assuming all your lines are in lower case
egrep "create table|alter table" file_a > file_b
# Or if they are mixed case or upper case
egrep -i "create table|alter table" file_a > file_b

Thanks for your reply.

Will egrep cut the lines from file_a?

Yes. egrep is just version of grep which in this context will do an or comparison. It's the same as grep -E .
As the command I posted does not affect the original file, while not try it?