{"id":1991,"date":"2024-01-03T15:55:03","date_gmt":"2024-01-03T23:55:03","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=1991"},"modified":"2024-01-04T16:53:22","modified_gmt":"2024-01-05T00:53:22","slug":"400-some-examples-of-sed-commands","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2024\/01\/400-some-examples-of-sed-commands\/","title":{"rendered":"#400 Some examples of SED commands"},"content":{"rendered":"<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nsed 's\/the\/THE\/' mytext.txt &gt; new.txt\r\nsed 's\/the\/THE\/g' mytext.txt &gt; new.txt\r\n# when it occurs 2nd time in every line\r\nsed 's\/the\/THE\/2' mytext.txt &gt; new.txt\r\n# other delimiter\r\nsed 's;half;1\/2;'  mytext.txt &gt; new.txt\r\n\/a.c\/ matches &quot;abc&quot; and &quot;axc&quot;\r\n\/a.c\/ does not math &quot;ac&quot;\r\n\/a.c\/ does not math &quot;axxc&quot;\r\n\/a\\.c\/ matches &quot;a.c&quot; \\. removes the special meaning of dot.\r\n\/a\\\\c\/ matches &quot;a\\c&quot;\r\n\/a\\\/c\/ matches &quot;a\/c&quot;\r\n\/^abc\/ matches first 3 characters in the line &quot;abcd&quot;\r\n\/^abc\/ does not match anything in the line &quot;dabc&quot;\r\n\/abc$\/ matches last 3 characters in the line &quot;dabc&quot;\r\n\/a&#x5B;xyz]c\/ matches &quot;axc&quot;, &quot;ayc&quot;, &quot;azc&quot;\r\n's\/&#x5B;Tt]th&#x5B;my]\/YOU\/g'\r\n\/a&#x5B;a-z]c\/ matches &quot;abc&quot; and any lower key letter from &#x5B;a-z]\r\n\/a&#x5B;a-zA-Z]c\/ matches &quot;abc&quot; and &quot;aBc&quot;\r\n's\/&#x5B;A-Z]&#x5B;a-z]&#x5B;a-z]\/FROG\/g'\r\n's\/&#x5B;a-zA-Z] \/* \/'\r\n's\/the&#x5B;^ ]\/YOU\/g'\r\n\/ab*c\/ matches &quot;abc&quot; and &quot;abbbbbc&quot;\r\n's\/t&#x5B;a-z]*\/ZOO\/g'\r\n's\/t&#x5B;a-z]&#x5B;a-z]&#x5B;a-z]*\/ZOO\/g'\r\n\/(ab)*c\/ matches &quot;ababababababc&quot;\r\ns'\/&#x5B;A-Z]&#x5B;a-z]*\/(&amp;)\/g'\r\n's\/\\(they\\) \\(were\\)\/\\2 \\1\/g'\r\n's\/\\(&#x5B;Tt&#x5B;hey\\) \\(were\\)\/\\2 \\1\/g'\r\n's\/they \\(&#x5B;a-z]*\\)\/\\1ed\/g'\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>sed &#8216;s\/the\/THE\/&#8217; mytext.txt &gt; new.txt sed &#8216;s\/the\/THE\/g&#8217; mytext.txt &gt; new.txt # when it occurs 2nd time in every line sed &#8216;s\/the\/THE\/2&#8217; mytext.txt &gt; new.txt # other delimiter sed &#8216;s;half;1\/2;&#8217; mytext.txt &gt; new.txt \/a.c\/ matches &quot;abc&quot; and &quot;axc&quot; \/a.c\/ does not math &quot;ac&quot; \/a.c\/ does not math &quot;axxc&quot; \/a\\.c\/ matches &quot;a.c&quot; \\. removes the special meaning [&hellip;]<\/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":[95],"tags":[],"class_list":["post-1991","post","type-post","status-publish","format-standard","hentry","category-sed"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-w7","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1971,"url":"https:\/\/gantovnik.com\/bio-tips\/2023\/11\/ex394\/","url_meta":{"origin":1991,"position":0},"title":"#394 Scatter plot of helix using matplotlib","author":"gantovnik","date":"2023-11-09","format":false,"excerpt":"[code language=\"python\"] import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np from numpy import sin, cos import pandas as pd fig = plt.figure() # preferred method for creating 3d axis ax = fig.add_subplot(111, projection='3d') r = 10 c = 2 t = np.linspace(0, 20, 400) # parametric\u2026","rel":"","context":"In &quot;matplotlib&quot;","block_context":{"text":"matplotlib","link":"https:\/\/gantovnik.com\/bio-tips\/category\/matplotlib\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/11\/ex394.png?fit=640%2C480&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/11\/ex394.png?fit=640%2C480&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2023\/11\/ex394.png?fit=640%2C480&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":679,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/118-how-can-i-get-mass-of-model-in-f06\/","url_meta":{"origin":1991,"position":1},"title":"#118: How to get mass of model in f06?","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"#117: How to get mass of model in f06? Case control entry: WEIGHTCHECK=YES p.s. This entry has much more options than to use older option PARAM,GRDPNT, 0 Output: [code language=\"python\"] O U T P U T F R O M W E I G H T C H E C\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":169,"url":"https:\/\/gantovnik.com\/bio-tips\/2019\/01\/lorenz-equations\/","url_meta":{"origin":1991,"position":2},"title":"Lorenz equations","author":"gantovnik","date":"2019-01-09","format":false,"excerpt":"import os import numpy as np import matplotlib.pyplot as plt from scipy import integrate from mpl_toolkits.mplot3d.axes3d import Axes3D os.chdir(r'D:\\projects\\wordpress\\ex36') os.getcwd() def f(xyz, t, rho, sigma, beta): x, y, z = xyz return [sigma*(y-x),x*(rho-z)-y,x*y-beta*z] rho = 28 sigma = 8 beta = 8\/3.0 t = np.linspace(0, 25, 10000) xyz0 = [1.0,\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example36.png?fit=1200%2C514&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example36.png?fit=1200%2C514&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example36.png?fit=1200%2C514&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example36.png?fit=1200%2C514&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2019\/01\/example36.png?fit=1200%2C514&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1592,"url":"https:\/\/gantovnik.com\/bio-tips\/2022\/10\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-3-2-2-3-2-2-3\/","url_meta":{"origin":1991,"position":3},"title":"#304 Julia set using Octave script","author":"gantovnik","date":"2022-10-23","format":false,"excerpt":"Place both files: julia.m and juliatest.m in the same folder: julia.m [code language=\"python\"] #{ Calculate a Julia set zmin = minimum value of c zmax = maximum value of c hpx = number of horizontal pixels niter = Number of iterations c = complex number #} function M = julia(zmin,\u2026","rel":"","context":"In &quot;octave&quot;","block_context":{"text":"octave","link":"https:\/\/gantovnik.com\/bio-tips\/category\/octave\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2022\/10\/2022-10-23_022754-300x239.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1201,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/210-parametric-curve-in-3d-2\/","url_meta":{"origin":1991,"position":4},"title":"#211 Lorenz attractor","author":"gantovnik","date":"2021-11-27","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt def lorenz(x, y, z, s=10, r=28, b=2.667): \"\"\" Given: x, y, z: a point of interest in three dimensional space s, r, b: parameters defining the lorenz attractor Returns: x_dot, y_dot, z_dot: values of the lorenz attractor's partial derivatives at\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex211.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1176,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/11\/204-mandelbrot-fractal-using-python\/","url_meta":{"origin":1991,"position":5},"title":"#204 Mandelbrot fractal using python","author":"gantovnik","date":"2021-11-26","format":false,"excerpt":"[code language=\"python\"] import numpy as np import matplotlib.pyplot as plt def mandelbrot(h,w, maxit=20): x,y = np.meshgrid(np.linspace(-2, 0.8, w), np.linspace(-1.4, 1.4, h)) c = x + y*1j z = c exceeds = np.zeros(z.shape, dtype=bool) for iteration in range(maxit): z = z**2 + c exceeded = abs(z) > 4 exceeds_now = exceeded\u2026","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2021\/11\/ex204.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1991","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=1991"}],"version-history":[{"count":1,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1991\/revisions"}],"predecessor-version":[{"id":2006,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/1991\/revisions\/2006"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=1991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=1991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=1991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}