{"id":566,"date":"2024-04-23T13:40:57","date_gmt":"2024-04-23T08:10:57","guid":{"rendered":"https:\/\/www.bhuvankrishna.in\/blog\/?p=566"},"modified":"2024-04-23T13:40:57","modified_gmt":"2024-04-23T08:10:57","slug":"experiments-with-awk","status":"publish","type":"post","link":"https:\/\/www.bhuvankrishna.in\/blog\/2024\/04\/23\/experiments-with-awk\/","title":{"rendered":"Experiments with AWK"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">These simple combination of commands are quite powerful. I am listing the commands that I used on some of the projects for later reference.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Find the number of columns and how many rows are there for those columns<br><code>awk -F, '{a[NF]++} END {for (e in a) {print e \":\" a[e]}}'<\/code> file.csv<br>output<br><code>3:13730<br>4:5<br>5:1<br>7:1<br>8:1<\/code><\/li>\n\n\n\n<li>Find the line with a given number of columns in a csv file. Update NF to the number of columns<br><code>awk -F, 'NF==4 {print NR, $0}' file.csv<\/code><\/li>\n\n\n\n<li><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>These simple combination of commands are quite powerful. I am listing the commands that I used on some of the projects for later reference.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-566","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/comments?post=566"}],"version-history":[{"count":1,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/566\/revisions"}],"predecessor-version":[{"id":567,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/posts\/566\/revisions\/567"}],"wp:attachment":[{"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/media?parent=566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/categories?post=566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bhuvankrishna.in\/blog\/wp-json\/wp\/v2\/tags?post=566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}