Simple script to cut a part out of a very big file

Every linux adminsitrator knows this problem: You have a very, really very big file like a great MySQL dump and now you need to cut a small part from it, like the create table definition of one single table.

It is quiet simple to find the line numbers that you want to cut from the file in this way:

This would give you for example a result like this:

So, if you, for example, need the create table definition for table “Table_E” you need to cut the part from line number 128 until line number 152.

You now can do this by calculating the number of lines and such and do this manually with some tail and head commands, but we have written a very small and handy script to manage this for you.

Just copy and paste the following code into a file like /usr/local/bin/cutter and then make it executable:

With this script you now can simple do something like this:

Hope this helps…  🙂

Best regards


About Christin Löhner (Linux Counter)

Leave a Reply