{"id":413,"date":"2008-01-09T22:36:09","date_gmt":"2008-01-09T21:36:09","guid":{"rendered":"http:\/\/wp.devco.net\/?p=413"},"modified":"2009-10-09T14:06:05","modified_gmt":"2009-10-09T13:06:05","slug":"extracting_only_certain_lines_from_a_file","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2008\/01\/09\/extracting_only_certain_lines_from_a_file.php","title":{"rendered":"Extracting only certain lines from a file"},"content":{"rendered":"

This is probably old news to most people but I need to remember this so I figured I may as well blog it.<\/p>\n

I made a mysqldump that just takes all databases into a single file, already I want to kick myself because I know if I ever need to import it there will be troubles because the target database will already have the mysql database etc.<\/p>\n

Really I should have used MySQL Parallel Dump<\/a> that makes files per tables etc and is much faster but it didn’t exist at the time.<\/p>\n

So how to pull lines 8596 to 9613 from this big file?  It’s trivial with sed:<\/p>\n

here is a sample file:<\/p>\n

\n
$ cat > file.txt\nline 1\nline 2\nline 3\nline 4\nline 5\n^D\n$ sed -n '2,4p;4q' file.txt\nline 2\nline 3\nline 4\n<\/pre>\n<\/blockquote>\n

The sed command just tells it the start to end line and also to quit processing when it hits the end line, really kewl.<\/p>\n","protected":false},"excerpt":{"rendered":"

This is probably old news to most people but I need to remember this so I figured I may as well blog it. I made a mysqldump that just takes all databases into a single file, already I want to kick myself because I know if I ever need to import it there will be […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","footnotes":""},"categories":[5],"tags":[19,33],"_links":{"self":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/413"}],"collection":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/comments?post=413"}],"version-history":[{"count":1,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/413\/revisions"}],"predecessor-version":[{"id":541,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/413\/revisions\/541"}],"wp:attachment":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/media?parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/categories?post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/tags?post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}