{"id":900,"date":"2021-02-19T15:09:00","date_gmt":"2021-02-19T23:09:00","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=900"},"modified":"2021-02-19T20:09:11","modified_gmt":"2021-02-20T04:09:11","slug":"162-loops-using-command-line-in-bash","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2021\/02\/162-loops-using-command-line-in-bash\/","title":{"rendered":"#162 Loops using command line in bash"},"content":{"rendered":"<p>With increment:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ for i in {1..20..2}; do echo $i; done\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n1\r\n3\r\n5\r\n7\r\n9\r\n11\r\n13\r\n15\r\n17\r\n19\r\n<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ for word in one two three; do echo $word; done\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\none\r\ntwo\r\nthree\r\n<\/pre>\n<p>C-like syntax:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ for ((i=1; i&lt;=4; i++)); do echo &quot;$i&quot;; done\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n1\r\n2\r\n3\r\n4\r\n<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ for file in $(ls *.dat); do echo &quot;nastran old=no news=no scr=yes $file que=default&quot; &gt;&gt; nastran_run.txt; done\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nnastran old=no news=no scr=yes model3_8.dat que=default\r\nnastran old=no news=no scr=yes model3_9.dat que=default\r\nnastran old=no news=no scr=yes model1_1.dat que=default\r\nnastran old=no news=no scr=yes model1_2.dat que=default\r\nnastran old=no news=no scr=yes model1_3.dat que=default\r\nnastran old=no news=no scr=yes model1_4.dat que=default\r\nnastran old=no news=no scr=yes model2_5.dat que=default\r\nnastran old=no news=no scr=yes model2_6.dat que=default\r\nnastran old=no news=no scr=yes model2_7.dat que=default\r\nnastran old=no news=no scr=yes model3_8.dat que=default\r\nnastran old=no news=no scr=yes model3_9.dat que=default\r\n<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ for file in $(ls *.{dat,bdf}); do echo &quot;nastran old=no news=no scr=yes $file que=default&quot; &gt;&gt; nastran_run.txt; done\r\n<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ rm nastran_run.txt; for file in $(ls *.dat | grep \\^model1 ); do echo &quot;nastran old=no news=no scr=yes $file que=default&quot; &gt;&gt; nastran_run.txt; done\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nnastran old=no news=no scr=yes model1_1.dat que=default\r\nnastran old=no news=no scr=yes model1_2.dat que=default\r\nnastran old=no news=no scr=yes model1_3.dat que=default\r\nnastran old=no news=no scr=yes model1_4.dat que=default\r\n<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ rm nastran_run.txt; for file in $(ls *.dat | grep \\^model2 ); do echo &quot;nastran old=no news=no scr=yes $file que=default&quot; &gt;&gt; nastran_run.txt; done\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nnastran old=no news=no scr=yes model1_1.dat que=default\r\nnastran old=no news=no scr=yes model1_2.dat que=default\r\nnastran old=no news=no scr=yes model1_3.dat que=default\r\nnastran old=no news=no scr=yes model1_4.dat que=default\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nnastran old=no news=no scr=yes model2_5.dat que=default\r\nnastran old=no news=no scr=yes model2_6.dat que=default\r\nnastran old=no news=no scr=yes model2_7.dat que=default\r\n<\/pre>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n$ rm nastran_run.txt; for file in $(ls *.dat | grep \\^model2 ); do echo &quot;nastran old=no news=no scr=yes $file que=default&quot; &gt;&gt; nastran_run.txt; done\r\n<\/pre>\n<p>Output:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nnastran old=no news=no scr=yes model3_8.dat que=default\r\nnastran old=no news=no scr=yes model3_9.dat que=default\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>With increment: $ for i in {1..20..2}; do echo $i; done Output: 1 3 5 7 9 11 13 15 17 19 $ for word in one two three; do echo $word; done Output: one two three C-like syntax: $ for ((i=1; i&lt;=4; i++)); do echo &quot;$i&quot;; done Output: 1 2 3 4 $ for [&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":[8,20],"tags":[],"class_list":["post-900","post","type-post","status-publish","format-standard","hentry","category-bash","category-linux"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-ew","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":688,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/121-windows-batch-script-to-run-every-nastran-input-file-in-folder\/","url_meta":{"origin":900,"position":0},"title":"#121: Windows batch script to run every Nastran input file in folder","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"This is an example of a Windows bat file to run Nastran for every *.dat file in the current folder. It also calculates the total Nastran execution time. Of course, you should change the path to nastran.exe. The nice thing here is that script uses variable set MyPath=%cd%, so you\u2026","rel":"","context":"In &quot;batch&quot;","block_context":{"text":"batch","link":"https:\/\/gantovnik.com\/bio-tips\/category\/batch\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":657,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/108-nastran-memory-settings\/","url_meta":{"origin":900,"position":1},"title":"#108: Nastran Memory Settings","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"#108: Nastran Memory Settings Memory is allocated on the MEM parameter. The MEM parameter cannot exceed memorymax. memorymax defaults to 50% of RAM and should not exceed 80% of physical RAM. It may be redefined on the command line or the RC file. The memory used by the solver can\u2026","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1458,"url":"https:\/\/gantovnik.com\/bio-tips\/2022\/05\/210-parametric-curve-in-3d-2-2-2-2-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2-2-2-2-2-3-2-2-2-2-2\/","url_meta":{"origin":900,"position":2},"title":"#281 How to convert numbers from Nastran notation to float","author":"gantovnik","date":"2022-05-29","format":false,"excerpt":"Often, it is necessary to convert numbers from Nastran notation to float. For example, convert -5.75-3 into -5.75e-3. We can write a simple python function for such conversion. [code language=\"python\"] #Convert -5.75-3 into -5.75e-3 ? def nastran2float(s): s = s.replace('-','e-') s = s.replace('+','e+') if s[0] == 'e': s = s[1:]\u2026","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":671,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/114-python-script-for-remove-offsets-from-cbar-elements\/","url_meta":{"origin":900,"position":3},"title":"#114: Python script for remove offsets from CBAR elements","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"#114: Python script for remove offsets from CBAR elements SOL 106 does not allow offsets in CBAR elements. [code language=\"python\"] print \"-------------------------------------\" print \"remove_cbush_offsets_v1.0\" print \"Vladimir Gantovnik\" print \"March 15 2016\" print \"-------------------------------------\" #input file inName='test.bdf' inFile=open(inName) #output file outName='stripped.bdf' outFile=open(outName,'w') import string while 1 : line=inFile.readline() if not line\u2026","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":660,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/109-how-to-output-the-stiffness-matrices-in-nastran\/","url_meta":{"origin":900,"position":4},"title":"#109: How to output the stiffness matrices in Nastran?","author":"gantovnik","date":"2020-09-28","format":false,"excerpt":"#109: How to output the stiffness matrices in Nastran? PARAM,EXTOUT,DMIGPCH The matrices will be printed in punch file *.pnch KAAX = boundary stiffness matrix PAX = boundary load matrix","rel":"","context":"In &quot;nastran&quot;","block_context":{"text":"nastran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/nastran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":632,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/09\/question-1-param-cards-in-nastran\/","url_meta":{"origin":900,"position":5},"title":"#99: PARAM cards in Nastran","author":"gantovnik","date":"2020-09-25","format":false,"excerpt":"#99: PARAM cards in Nastran 1) K6ROT specifies the stiffness to be added to the normal rotation for CQUAD4 and CTRIA3 elements. This is an alternate method to suppress the grid point singularities and is intended primarily for geometric nonlinear analysis. A value between 1.0 and 100.0 is recommended to\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/900","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=900"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/900\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}