Skip to main content

Posts

Showing posts from June, 2021

Grepping huge file with fgrep

  https://stackoverflow.com/questions/13913014/grepping-a-huge-file-80gb-any-way-to-speed-it-up LC_ALL=C fgrep -A 5 -B 5 'db_pd.Clients' eightygigsfile.sql -A 5 -B 5 mean get 5 lines in for example CREATE TABLE `r1_category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cat_name` varchar(100) NOT NULL, `caption` varchar(100) NOT NULL, `cat_caption` varchar(100) NOT NULL, `coupon_catid` int(11) DEFAULT NULL, // Trimmed line KEY `cat_name` (`cat_name`,`discount_status`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; => If you want full columns in CREATE query, increase A B parameter: LC_ALL=C fgrep -A 15 -B 15 'db_pd.Clients' eightygigsfile.sql > Client.sql // grep -Fn --text "1-Piston Calipers; Oversized" product_NOV_22.csv // -F for treat input pattern search as fixed string