{"id":80,"date":"2018-12-29T07:24:15","date_gmt":"2018-12-29T07:24:15","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=80"},"modified":"2018-12-29T07:24:15","modified_gmt":"2018-12-29T07:24:15","slug":"add-numbers-in-the-first-and-third-columns","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2018\/12\/add-numbers-in-the-first-and-third-columns\/","title":{"rendered":"Add numbers in the first and third columns"},"content":{"rendered":"<pre>awk '{ print $1+$3 }' sample.txt<\/pre>\n<p>&nbsp;<\/p>\n<pre>#sample.txt\n1 1 1 3\n2 1 2 3\n3 1 3 3<\/pre>\n<p>&nbsp;<\/p>\n<pre>$result\n2\n4\n6<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>awk &#8216;{ print $1+$3 }&#8217; sample.txt &nbsp; #sample.txt 1 1 1 3 2 1 2 3 3 1 3 3 &nbsp; $result 2 4 6 &nbsp;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-bash"],"modified_by":null,"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-1i","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":78,"url":"https:\/\/gantovnik.com\/bio-tips\/2018\/12\/sum-data-in-columns-in-a-fixed-width-text-file\/","url_meta":{"origin":80,"position":0},"title":"Sum data in columns in a fixed width text file","author":"gantovnik","date":"2018-12-29","format":false,"excerpt":"declare -i SW=0 SX=0 SY=0 SZ=0 while IFS='' read LINE; do SW+=${LINE:0:5} ; SX+=${LINE:5:5} SY+=${LINE:10:5} ; SZ+=${LINE:15:5} done < sample.txt printf \" %4d %4d %4d %4d\\n\" $S{W,X,Y,Z} #sample.txt 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 1 1\u2026","rel":"","context":"In &quot;bash&quot;","block_context":{"text":"bash","link":"https:\/\/gantovnik.com\/bio-tips\/category\/bash\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1901,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/07\/367-extracting-columns-of-the-data-file-using-awk\/","url_meta":{"origin":80,"position":1},"title":"#367 Extracting columns of the data file using awk.","author":"gantovnik","date":"2023-07-20","format":false,"excerpt":"example.csv ex366.txt variant: output:","rel":"","context":"In &quot;awk&quot;","block_context":{"text":"awk","link":"https:\/\/gantovnik.com\/bio-tips\/category\/awk\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1750,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/01\/332-remove-duplicates-by-columns-and-keep-the-row-with-the-highest-value-in-the-selected-column-by-pandas\/","url_meta":{"origin":80,"position":2},"title":"#332 Remove duplicates by columns and keep the row with the highest value in the selected column by pandas","author":"gantovnik","date":"2023-01-05","format":false,"excerpt":"table.txt ex332.py Output:","rel":"","context":"In &quot;pandas&quot;","block_context":{"text":"pandas","link":"https:\/\/gantovnik.com\/bio-tips\/category\/pandas\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":886,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/02\/157-formatting-output-in-awk\/","url_meta":{"origin":80,"position":3},"title":"#157 Formatting output in awk","author":"gantovnik","date":"2021-02-09","format":false,"excerpt":"#157 Formatting output in awk Without formatting, the command look like this The same command with formatting With the header information added to the BEGIN block:","rel":"","context":"In &quot;awk&quot;","block_context":{"text":"awk","link":"https:\/\/gantovnik.com\/bio-tips\/category\/awk\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":833,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/01\/147-count-the-total-number-of-fields-in-a-file-using-awk\/","url_meta":{"origin":80,"position":4},"title":"#147 Count the total number of fields in a file using awk","author":"gantovnik","date":"2021-01-14","format":false,"excerpt":"#147 Count the total number of fields in a file using awk Assume we have \"test1.txt\" file with data in columns: Save the following awk script in the file \"ex147.awk\" Run file \"ex147run.txt\" using The result is 16.","rel":"","context":"In &quot;awk&quot;","block_context":{"text":"awk","link":"https:\/\/gantovnik.com\/bio-tips\/category\/awk\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2148,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/04\/419-random-permutations-using-numpy\/","url_meta":{"origin":80,"position":5},"title":"#419 Random permutations using numpy","author":"gantovnik","date":"2024-04-21","format":false,"excerpt":"Output:","rel":"","context":"In &quot;numpy&quot;","block_context":{"text":"numpy","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/numpy\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}