{"id":235,"date":"2012-02-09T01:26:22","date_gmt":"2012-02-09T01:26:22","guid":{"rendered":"http:\/\/joelinoff.com\/blog\/?page_id=235"},"modified":"2013-11-21T16:17:38","modified_gmt":"2013-11-21T16:17:38","slug":"syntax-for-some-bash-and-tcsh-commands","status":"publish","type":"page","link":"https:\/\/joelinoff.com\/blog\/?page_id=235","title":{"rendered":"Translate between bash and tcsh commands"},"content":{"rendered":"<h2>Table of Contents<\/h2>\n<ol>\n<li><a href=\"#tbl\">Bash\/Tcsh Comparison Table<\/a><\/li>\n<li><a href=\"#gen\">How It Was Generated<\/a><\/li>\n<li><a href=\"#make\">Makefile<\/a><\/li>\n<li><a href=\"#genhtml\">Generate HTML (genhtml.py)<\/a><\/li>\n<li><a href=\"#bash\">Bash Commands Script (compare.sh)<\/a><\/li>\n<li><a href=\"#tcsh\">Tcsh Commands Script (compare.csh)<\/a><\/li>\n<\/ol>\n<p><a name=\"tbl\"><\/a><\/p>\n<h2>Bash\/Tcsh Comparison Table<\/h2>\n<p>The table below shows bash commands and their equivalents in tcsh along with the tools that I wrote to create it.<\/p>\n<p>I put it together because I sometimes have to switch between shells and needed a handy reference. It was built up over time by as I came across tidbits that I wanted to remember.<\/p>\n<p>In some cases there are different ways of doing the same thing so I simply chose my preferred approach (such as [[]] expressions rather than [] in the if statements).<\/p>\n<p>I hope that you find it useful.<\/p>\n<style type=\"text\/css\">\n      table.mytable {\n        font-family: Arial, Helvetica; \n        font-size: 1.2em;\n        border-collapse: separate;\n        border-spacing: 1px;\n        *border-collapse: expression('separate', cellSpacing = '1px');\n        border: 2px solid lightgray;\n      }\n      tr.myrow-even {\n        vertical-align: top;\n        background-color: #ffffea;\n        border: 2px solid lightgray;\n      }\n      tr.myrow-odd {\n        vertical-align: top;\n        background-color: none;\n        border: 2px solid lightgray;\n      }\n      th.mycell-hdr {\n        vertical-align: top;\n        text-align: center;\n        padding: 4px 4px;\n        border: 2px solid lightgray;\n        \/*font-size: 1.3em;*\/\n      }\n      td.mycell-id {\n        vertical-align: top;\n        text-align: right;\n        padding: 2px 2px;\n        border: 1px solid lightgray;\n        font-size: 0.9em;\n        line-height: 100%;\n      }\n      td.mycell-title {\n        vertical-align: top;\n        text-align: left;\n        padding: 2px 2px;\n        border: 1px solid lightgray;\n        font-size: 0.9em;\n        line-height: 100%;\n      }\n      td.mycell-code {\n        vertical-align: top;\n        font-family: \"Courier New\", monospace; \n        text-align: left;\n        padding: 2px 2px;\n        border: 1px solid lightgray;\n        font-size: 0.9em;\n        line-height: 100%;\n      }\n      div#mydiv {\n        margin-left: -30px;\n        width: 110%;\n      }\n    <\/style>\n<div id=\"mydiv\">\n<table>\n<thead>\n<tr bgcolor=\"#DDDDDD\">\n<th class=\"mycell-hdr\">ID<\/th>\n<th class=\"mycell-hdr\">Operation<\/th>\n<th class=\"mycell-hdr\">bash<\/th>\n<th class=\"mycell-hdr\">tcsh<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">1<\/td>\n<td class=\"mycell-title\">alias<\/td>\n<td class=\"mycell-code\">alias&nbsp;foo=bar<\/td>\n<td class=\"mycell-code\">alias&nbsp;foo&nbsp;bar<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">2<\/td>\n<td class=\"mycell-title\">array: declaration<\/td>\n<td class=\"mycell-code\">ARRAY=(&quot;a&quot;&nbsp;&quot;b&quot;&nbsp;&quot;c&quot;)<\/td>\n<td class=\"mycell-code\">set&nbsp;ARRAY&nbsp;=&nbsp;(&quot;a&quot;&nbsp;&quot;b&quot;&nbsp;&quot;c&quot;)<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">3<\/td>\n<td class=\"mycell-title\">array: first item<\/td>\n<td class=\"mycell-code\">echo&nbsp;first&nbsp;item&nbsp;[0]&nbsp;=&nbsp;${ARRAY[0]}<\/td>\n<td class=\"mycell-code\">echo&nbsp;&quot;first&nbsp;item&nbsp;[1]&nbsp;=&nbsp;$ARRAY[1]&quot;<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">4<\/td>\n<td class=\"mycell-title\">array: iterate by index<\/td>\n<td class=\"mycell-code\">for&nbsp;i&nbsp;in&nbsp;${!ARRAY[@]};&nbsp;do<br \/>&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;&quot;%d&nbsp;%s\\n&quot;&nbsp;$i&nbsp;${ARRAY[i]}<br \/>done<\/td>\n<td class=\"mycell-code\">foreach&nbsp;i&nbsp;(&nbsp;&#96;seq&nbsp;$#ARRAY&#96;&nbsp;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$i&nbsp;$ARRAY[$i]&nbsp;|\\<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;awk&nbsp;&apos;{printf(&quot;%d&nbsp;%s\\n&quot;,$1,$2);}&apos;<br \/>end<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">5<\/td>\n<td class=\"mycell-title\">array: iterate by item<\/td>\n<td class=\"mycell-code\">for&nbsp;item&nbsp;in&nbsp;${ARRAY[@]}&nbsp;;&nbsp;do<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;item&nbsp;=&nbsp;$item<br \/>done<\/td>\n<td class=\"mycell-code\">foreach&nbsp;item&nbsp;(&nbsp;$ARRAY&nbsp;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;item&nbsp;=&nbsp;$item<br \/>end<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">6<\/td>\n<td class=\"mycell-title\">array: iterate by item, single line<\/td>\n<td class=\"mycell-code\">A=(&quot;a&quot;&nbsp;&quot;b&quot;&nbsp;&quot;c&quot;)<br \/>for&nbsp;x&nbsp;in&nbsp;${A[@]}&nbsp;;&nbsp;do&nbsp;echo&nbsp;$x;&nbsp;done<\/td>\n<td class=\"mycell-code\">N\/A<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">7<\/td>\n<td class=\"mycell-title\">array: size<\/td>\n<td class=\"mycell-code\">echo&nbsp;${#ARRAY[@]}&nbsp;items<\/td>\n<td class=\"mycell-code\">echo&nbsp;$#ARRAY&nbsp;items<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">8<\/td>\n<td class=\"mycell-title\">command substitution<\/td>\n<td class=\"mycell-code\">#&nbsp;style&nbsp;1&nbsp;&ndash;&nbsp;can&apos;t&nbsp;be&nbsp;nested<br \/>x=&#96;ls&nbsp;&ndash;1&#96;<br \/>#&nbsp;style&nbsp;2&nbsp;&ndash;&nbsp;can&nbsp;be&nbsp;nested<br \/>me=$(dirname&nbsp;&ndash;&ndash;&nbsp;$(readlink&nbsp;&ndash;f&nbsp;.))<br \/>echo&nbsp;$me<\/td>\n<td class=\"mycell-code\">#&nbsp;style&nbsp;1&nbsp;&ndash;&nbsp;can&apos;t&nbsp;be&nbsp;nested<br \/>set&nbsp;x&nbsp;=&nbsp;&#96;ls&nbsp;&ndash;1&#96;<br \/>#&nbsp;style&nbsp;2&nbsp;&ndash;&nbsp;not&nbsp;supported<br \/>set&nbsp;r&nbsp;=&nbsp;&#96;readlink&nbsp;&ndash;f&nbsp;.&#96;<br \/>set&nbsp;me&nbsp;=&nbsp;&#96;dirname&nbsp;$r&#96;<br \/>echo&nbsp;$me<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">9<\/td>\n<td class=\"mycell-title\">exit the shell<\/td>\n<td class=\"mycell-code\">exit<br \/>exit&nbsp;1<\/td>\n<td class=\"mycell-code\">exit<br \/>exit&nbsp;1<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">10<\/td>\n<td class=\"mycell-title\">formatted printing<\/td>\n<td class=\"mycell-code\">#&nbsp;Native&nbsp;support.<br \/>printf&nbsp;&quot;%05d&nbsp;%s\\n&quot;&nbsp;42&nbsp;&quot;Deep&nbsp;Thought&quot;<\/td>\n<td class=\"mycell-code\">#&nbsp;No&nbsp;native&nbsp;support,<br \/>#&nbsp;emulate&nbsp;with&nbsp;awk.<br \/>#&nbsp;Embedded&nbsp;spaces&nbsp;are&nbsp;a&nbsp;pain.<br \/>echo&nbsp;42&nbsp;&quot;Deep&nbsp;Thought&quot;&nbsp;|\\<br \/>&nbsp;&nbsp;awk&nbsp;&apos;{printf(&quot;%05d&nbsp;%s&nbsp;%s\\n&quot;,$1,$2,$3);&apos;}<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">11<\/td>\n<td class=\"mycell-title\">function<\/td>\n<td class=\"mycell-code\">function&nbsp;echo&ndash;cmds&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;CMD&nbsp;:&nbsp;&quot;$*<br \/>&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Echo&nbsp;the&nbsp;commands.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;local&nbsp;args=&quot;$@&quot;&nbsp;#&nbsp;local&nbsp;var<br \/>&nbsp;&nbsp;&nbsp;&nbsp;$args&nbsp;|&nbsp;sed&nbsp;&ndash;e&nbsp;&apos;s\/^\/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/&apos;<br \/>}<br \/>echo&ndash;cmds&nbsp;pwd<br \/>echo&ndash;cmds&nbsp;ls&nbsp;&ndash;l<\/td>\n<td class=\"mycell-code\">N\/A<br \/>Can&nbsp;be&nbsp;emulated&nbsp;using<br \/>external&nbsp;scripts<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">12<\/td>\n<td class=\"mycell-title\">get shell name<\/td>\n<td class=\"mycell-code\">echo&nbsp;$SHELL<\/td>\n<td class=\"mycell-code\">echo&nbsp;$shell<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">13<\/td>\n<td class=\"mycell-title\">get shell version<\/td>\n<td class=\"mycell-code\">bash&nbsp;&ndash;&ndash;version<br \/>echo&nbsp;$BASH_VERSION<\/td>\n<td class=\"mycell-code\">tcsh&nbsp;&ndash;&ndash;version<br \/>echo&nbsp;$version<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">14<\/td>\n<td class=\"mycell-title\">if\/then\/else: numeric<\/td>\n<td class=\"mycell-code\">i=2<br \/>if&nbsp;((&nbsp;i&gt;2&nbsp;))&nbsp;;&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;i&nbsp;greater&nbsp;than&nbsp;2<br \/>elif&nbsp;((&nbsp;i&lt;2&nbsp;))&nbsp;;&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;i&nbsp;less&nbsp;than&nbsp;2<br \/>else<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;i&nbsp;is&nbsp;two<br \/>fi<\/td>\n<td class=\"mycell-code\">set&nbsp;i=2<br \/>if&nbsp;($i&gt;2)&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;i&nbsp;greater&nbsp;than&nbsp;2<br \/>else&nbsp;if&nbsp;($i&lt;2)&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;i&nbsp;less&nbsp;than&nbsp;2<br \/>else<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;i&nbsp;is&nbsp;two<br \/>endif<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">15<\/td>\n<td class=\"mycell-title\">if\/then\/else: string<\/td>\n<td class=\"mycell-code\">s=&quot;foo&nbsp;bar&quot;<br \/>if&nbsp;[[&nbsp;&quot;$s&quot;&nbsp;==&nbsp;&quot;foo&nbsp;bar&quot;&nbsp;]]&nbsp;;&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;foo&quot;<br \/>else<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;spam&quot;<br \/>fi<\/td>\n<td class=\"mycell-code\">set&nbsp;s=&quot;foo&nbsp;bar&quot;<br \/>if&nbsp;(&quot;$s&quot;&nbsp;==&nbsp;&quot;foo&nbsp;bar&quot;)&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;foo&quot;<br \/>else<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;spam&quot;<br \/>endif<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">16<\/td>\n<td class=\"mycell-title\">include a file<\/td>\n<td class=\"mycell-code\">source&nbsp;include&ndash;file<br \/>.&nbsp;&nbsp;include&ndash;file<\/td>\n<td class=\"mycell-code\">source&nbsp;include&ndash;file<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">17<\/td>\n<td class=\"mycell-title\">IO: redirect stderr<\/td>\n<td class=\"mycell-code\">ls&nbsp;2&gt;&nbsp;\/tmp\/$$<\/td>\n<td class=\"mycell-code\">(&nbsp;ls&nbsp;&gt;&nbsp;\/dev\/tty&nbsp;)&nbsp;&gt;&amp;&nbsp;\/tmp\/$$<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">18<\/td>\n<td class=\"mycell-title\">IO: redirect stdout<\/td>\n<td class=\"mycell-code\">ls&nbsp;&gt;&nbsp;\/tmp\/$$<\/td>\n<td class=\"mycell-code\">ls&nbsp;&gt;&nbsp;\/tmp\/$$<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">19<\/td>\n<td class=\"mycell-title\">IO: redirect stdout and stderr<\/td>\n<td class=\"mycell-code\">ls&nbsp;&gt;&nbsp;\/tmp\/$$&nbsp;2&gt;&amp;1&nbsp;#&nbsp;older<br \/>ls&nbsp;&amp;&gt;&nbsp;\/tmp\/$$&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;newer<\/td>\n<td class=\"mycell-code\">ls&nbsp;&gt;&amp;&nbsp;\/tmp\/$$<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">20<\/td>\n<td class=\"mycell-title\">job: move into the background<\/td>\n<td class=\"mycell-code\">job<br \/>&lt;Ctrl&ndash;Z&gt;<br \/>bg<\/td>\n<td class=\"mycell-code\">job<br \/>&lt;Ctrl&ndash;Z&gt;<br \/>bg<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">21<\/td>\n<td class=\"mycell-title\">job: move into the foreground<\/td>\n<td class=\"mycell-code\">fg<br \/>fg&nbsp;%1<\/td>\n<td class=\"mycell-code\">fg<br \/>fg&nbsp;%1<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">22<\/td>\n<td class=\"mycell-title\">job: start in the background<\/td>\n<td class=\"mycell-code\">job&nbsp;&amp;<\/td>\n<td class=\"mycell-code\">job&nbsp;&amp;<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">23<\/td>\n<td class=\"mycell-title\">job: status<\/td>\n<td class=\"mycell-code\">job<br \/>echo&nbsp;status&nbsp;=&nbsp;$?<\/td>\n<td class=\"mycell-code\">job<br \/>echo&nbsp;status&nbsp;=&nbsp;$?<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">24<\/td>\n<td class=\"mycell-title\">local variable<\/td>\n<td class=\"mycell-code\">function&nbsp;fct&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;local&nbsp;var=&apos;local&apos;<br \/>}<\/td>\n<td class=\"mycell-code\">#&nbsp;functions&nbsp;not&nbsp;supported<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">25<\/td>\n<td class=\"mycell-title\">prompt<\/td>\n<td class=\"mycell-code\">set&nbsp;PS1=&apos;\\u&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;user&nbsp;name<br \/>set&nbsp;PS1=&apos;\\h&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;host<br \/>set&nbsp;PS1=&apos;\\!&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;command&nbsp;num<br \/>#set&nbsp;PS1=N\/A&nbsp;&gt;&apos;&nbsp;#&nbsp;last&nbsp;3&nbsp;dir&nbsp;parts<br \/>set&nbsp;PS1=&apos;\\W&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;last&nbsp;dir&nbsp;part<br \/>set&nbsp;PS1=&apos;\\w&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;curr&nbsp;dir&nbsp;full<br \/>set&nbsp;PS1=&apos;\\v&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;shell&nbsp;version<br \/>set&nbsp;PS1=&apos;\\u@\\h&nbsp;\\W&nbsp;(\\!)&nbsp;&gt;&apos;<\/td>\n<td class=\"mycell-code\">set&nbsp;prompt=&apos;%n&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;user&nbsp;name<br \/>set&nbsp;prompt=&apos;%j&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;host<br \/>set&nbsp;prompt=&apos;!&nbsp;&gt;&apos;&nbsp;&nbsp;&nbsp;#&nbsp;command&nbsp;num<br \/>set&nbsp;prompt=&apos;%c3&nbsp;&gt;&apos;&nbsp;#&nbsp;last&nbsp;3&nbsp;dir&nbsp;parts<br \/>set&nbsp;prompt=&apos;%c&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;last&nbsp;dir&nbsp;part<br \/>set&nbsp;prompt=&apos;%~&nbsp;&gt;&apos;&nbsp;&nbsp;#&nbsp;curr&nbsp;dir&nbsp;full<br \/>#set&nbsp;prompt=N\/A&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;shell&nbsp;version<br \/>set&nbsp;prompt=&apos;%n@%j&nbsp;%c&nbsp;(!)&nbsp;&gt;&apos;<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">26<\/td>\n<td class=\"mycell-title\">range iteration<\/td>\n<td class=\"mycell-code\">for&nbsp;i&nbsp;in&nbsp;&#96;seq&nbsp;1000&#96;&nbsp;;&nbsp;do<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$i<br \/>done<\/p>\n<p>for&nbsp;i&nbsp;in&nbsp;$(&nbsp;seq&nbsp;1000&nbsp;)&nbsp;;&nbsp;do<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$i<br \/>done<\/p>\n<p>#&nbsp;fastest<br \/>for&nbsp;i&nbsp;in&nbsp;{1..1000}&nbsp;;&nbsp;do<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$i<br \/>done<\/td>\n<td class=\"mycell-code\">foreach&nbsp;i&nbsp;(&nbsp;&#96;seq&nbsp;1000&#96;&nbsp;)<br \/>&nbsp;&nbsp;echo&nbsp;$i<br \/>end<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">27<\/td>\n<td class=\"mycell-title\">read values from the console<\/td>\n<td class=\"mycell-code\">read&nbsp;&ndash;p&nbsp;&quot;login?&nbsp;&quot;&nbsp;login<br \/>read&nbsp;&ndash;p&nbsp;&quot;passwd?&nbsp;&quot;&nbsp;&ndash;s&nbsp;passwd<br \/>echo<br \/>echo&nbsp;&quot;login:&nbsp;$login&quot;<br \/>echo&nbsp;&quot;passwd:&nbsp;$passwd&quot;<\/td>\n<td class=\"mycell-code\">echo&nbsp;&ndash;n&nbsp;&quot;login?&nbsp;&quot;<br \/>set&nbsp;login&nbsp;=&nbsp;$&lt;<\/p>\n<p>echo&nbsp;&ndash;n&nbsp;&quot;passwd?&nbsp;&quot;<br \/>stty&nbsp;&ndash;echo<br \/>set&nbsp;passwd&nbsp;=&nbsp;$&lt;<br \/>stty&nbsp;echo<\/p>\n<p>echo<br \/>echo&nbsp;&quot;login:&nbsp;$login&quot;<br \/>echo&nbsp;&quot;passwd:&nbsp;$passwd&quot;<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">28<\/td>\n<td class=\"mycell-title\">regex extension check<\/td>\n<td class=\"mycell-code\">FILES=(&apos;f1.tar.bz2&apos;&nbsp;&apos;f2.tar.gz&apos;&nbsp;&apos;f3.zip&apos;)<br \/>for&nbsp;FILE&nbsp;in&nbsp;${FILES[@]}&nbsp;;&nbsp;do<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;[[&nbsp;&quot;$FILE&quot;&nbsp;=~&nbsp;.tar.bz2$&nbsp;]]&nbsp;;&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;tar.bz2:&nbsp;$FILE&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;[[&nbsp;&quot;$FILE&quot;&nbsp;=~&nbsp;.tar.gz$&nbsp;]]&nbsp;;&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;tar.gz:&nbsp;$FILE&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;[[&nbsp;&quot;$FILE&quot;&nbsp;=~&nbsp;.zip$&nbsp;]]&nbsp;;&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;zip:&nbsp;$FILE&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;else<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;unk:&nbsp;$FILE&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;fi<br \/>done<\/td>\n<td class=\"mycell-code\">set&nbsp;FILES=(&apos;f1.tar.bz2&apos;&nbsp;&apos;f2.tar.gz&apos;&nbsp;&apos;f3.zip&apos;)<br \/>foreach&nbsp;FILE&nbsp;(&nbsp;$FILES&nbsp;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$FILE&nbsp;|&nbsp;grep&nbsp;&apos;.tar.bz2$&apos;&nbsp;&gt;&amp;\/dev\/null<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;$?&nbsp;==&nbsp;0&nbsp;)&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;tar.bz2:&nbsp;$FILE&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br \/>&nbsp;&nbsp;&nbsp;&nbsp;endif<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$FILE&nbsp;|&nbsp;grep&nbsp;&apos;.tar.gz$&apos;&nbsp;&gt;&amp;\/dev\/null<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;$?&nbsp;==&nbsp;0&nbsp;)&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;tar.gz:&nbsp;$FILE&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br \/>&nbsp;&nbsp;&nbsp;&nbsp;endif<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$FILE&nbsp;|&nbsp;grep&nbsp;&apos;.zip$&apos;&nbsp;&gt;&amp;\/dev\/null<br \/>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;$?&nbsp;==&nbsp;0&nbsp;)&nbsp;then<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;zip:&nbsp;$FILE&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue<br \/>&nbsp;&nbsp;&nbsp;&nbsp;endif<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;unk:&nbsp;$FILE&quot;<br \/>end<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">29<\/td>\n<td class=\"mycell-title\">set path variable<\/td>\n<td class=\"mycell-code\">export&nbsp;PATH=&quot;$PATH:\/tmp&quot;<\/td>\n<td class=\"mycell-code\">set&nbsp;path&nbsp;=&nbsp;(&nbsp;$path&nbsp;\/tmp&nbsp;)<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">30<\/td>\n<td class=\"mycell-title\">set resource limits<\/td>\n<td class=\"mycell-code\">ulimit<\/td>\n<td class=\"mycell-code\">limit<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">31<\/td>\n<td class=\"mycell-title\">setenv\/export<\/td>\n<td class=\"mycell-code\">export&nbsp;FOOBAR=&quot;spam&quot;<\/td>\n<td class=\"mycell-code\">setenv&nbsp;FOOBAR&nbsp;&quot;spam&quot;<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">32<\/td>\n<td class=\"mycell-title\">switch statement<\/td>\n<td class=\"mycell-code\">arg=&quot;foo&quot;<br \/>case&nbsp;&quot;$arg&quot;&nbsp;in<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&quot;foo&quot;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;foo&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&quot;bar&quot;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;bar&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&quot;spam&quot;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;spam&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;*)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;be&nbsp;do&nbsp;be&nbsp;do&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;<br \/>esac<\/td>\n<td class=\"mycell-code\">set&nbsp;arg=&quot;foo&quot;<br \/>switch&nbsp;(&quot;$arg&quot;)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;&quot;foo&quot;:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;foo&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;breaksw<br \/>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;&quot;bar&quot;:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;bar&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;breaksw<br \/>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;&quot;spam&quot;:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;spam&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;breaksw<br \/>&nbsp;&nbsp;&nbsp;&nbsp;default:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;&quot;do&nbsp;be&nbsp;do&nbsp;be&nbsp;do&quot;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;breaksw<br \/>endsw<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">33<\/td>\n<td class=\"mycell-title\">variable: auto decrement<\/td>\n<td class=\"mycell-code\">i=0<br \/>((&nbsp;i&ndash;&ndash;&nbsp;))<br \/>echo&nbsp;auto&nbsp;deccrement&nbsp;=&nbsp;$i<\/td>\n<td class=\"mycell-code\">set&nbsp;i=0<br \/>@&nbsp;i&ndash;&ndash;<br \/>echo&nbsp;auto&nbsp;decrement&nbsp;=&nbsp;$i<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">34<\/td>\n<td class=\"mycell-title\">variable: auto increment<\/td>\n<td class=\"mycell-code\">i=0<br \/>((&nbsp;i++&nbsp;))<br \/>echo&nbsp;auto&nbsp;increment&nbsp;=&nbsp;$i<\/td>\n<td class=\"mycell-code\">set&nbsp;i=0<br \/>@&nbsp;i++<br \/>echo&nbsp;auto&nbsp;increment&nbsp;=&nbsp;$i<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">35<\/td>\n<td class=\"mycell-title\">variable: automatically exit on error<\/td>\n<td class=\"mycell-code\">\/bin\/bash&nbsp;&ndash;e&nbsp;#&nbsp;invocation<br \/>set&nbsp;&ndash;e&nbsp;#&nbsp;inside&nbsp;the&nbsp;shell<\/td>\n<td class=\"mycell-code\">\/bin\/tcsh&nbsp;&ndash;e&nbsp;#&nbsp;invocation&nbsp;only<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">36<\/td>\n<td class=\"mycell-title\">variable: create array<\/td>\n<td class=\"mycell-code\">ARRAY=(&quot;item1&quot;&nbsp;&quot;item2&quot;&nbsp;&quot;item2&quot;)<\/td>\n<td class=\"mycell-code\">set&nbsp;ARRAY=(&quot;item1&quot;&nbsp;&quot;item2&quot;&nbsp;&quot;item2&quot;)<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">37<\/td>\n<td class=\"mycell-title\">variable: create scalar<\/td>\n<td class=\"mycell-code\">i=0<br \/>s=&quot;foo&nbsp;bar&nbsp;spam&quot;<\/td>\n<td class=\"mycell-code\">set&nbsp;i=0<br \/>set=&quot;foo&nbsp;bar&nbsp;spam&quot;<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">38<\/td>\n<td class=\"mycell-title\">variable: debug tracing<\/td>\n<td class=\"mycell-code\">set&nbsp;&ndash;x&nbsp;#&nbsp;on<br \/>pwd<br \/>set&nbsp;+x&nbsp;#&nbsp;off<br \/>pwd<\/td>\n<td class=\"mycell-code\">set&nbsp;verbose&nbsp;#&nbsp;on<br \/>pwd<br \/>unset&nbsp;verbose&nbsp;#&nbsp;off<br \/>pwd<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">39<\/td>\n<td class=\"mycell-title\">variable: destroy or unset<\/td>\n<td class=\"mycell-code\">ARRAY=(&quot;item1&quot;&nbsp;&quot;item2&quot;&nbsp;&quot;item2&quot;)<br \/>unset&nbsp;ARRAY<\/td>\n<td class=\"mycell-code\">set&nbsp;ARRAY=(&quot;item1&quot;&nbsp;&quot;item2&quot;&nbsp;&quot;item2&quot;)<br \/>unset&nbsp;ARRAY<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">40<\/td>\n<td class=\"mycell-title\">variable: dump state<\/td>\n<td class=\"mycell-code\">set<\/td>\n<td class=\"mycell-code\">set<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">41<\/td>\n<td class=\"mycell-title\">variable: dynamic<\/td>\n<td class=\"mycell-code\">#&nbsp;Native&nbsp;support,&nbsp;can&nbsp;also&nbsp;use&nbsp;eval.<br \/>a=&quot;some&nbsp;value&quot;<br \/>b=a<br \/>echo&nbsp;$b&nbsp;=&nbsp;${!b}<br \/>bv=&quot;${!b}&quot;<br \/>echo&nbsp;bv&nbsp;=&nbsp;$bv<\/td>\n<td class=\"mycell-code\">#&nbsp;Not&nbsp;native,&nbsp;need&nbsp;to&nbsp;use&nbsp;eval.<br \/>set&nbsp;a=&quot;some&nbsp;value&quot;<br \/>set&nbsp;b=&quot;a&quot;<br \/>eval&nbsp;&quot;echo&nbsp;$b&nbsp;=&nbsp;&quot;&apos;$&apos;${b}<br \/>set&nbsp;bv=&#96;eval&nbsp;echo&nbsp;&apos;$&apos;$b&#96;<br \/>echo&nbsp;bv&nbsp;=&nbsp;$bv<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">42<\/td>\n<td class=\"mycell-title\">variable: print environment variables<\/td>\n<td class=\"mycell-code\">env<br \/>printenv<\/td>\n<td class=\"mycell-code\">env<br \/>printenv<\/td>\n<\/tr>\n<tr class=\"myrow-even\">\n<td class=\"mycell-id\">43<\/td>\n<td class=\"mycell-title\">variable: substitution<\/td>\n<td class=\"mycell-code\">foo=&apos;bar&apos;<br \/>echo&nbsp;${foo\/bar\/baz\/}<\/td>\n<td class=\"mycell-code\">set&nbsp;foo&nbsp;=&nbsp;&apos;bar&apos;<br \/>echo&nbsp;$foo:s\/bar\/baz\/<\/td>\n<\/tr>\n<tr class=\"myrow-odd\">\n<td class=\"mycell-id\">44<\/td>\n<td class=\"mycell-title\">variable: turn on unset variable checking<\/td>\n<td class=\"mycell-code\">set&nbsp;&ndash;u<\/td>\n<td class=\"mycell-code\">N\/A<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n<p><a name=\"gen\"><\/a><\/p>\n<h2>How It Was Generated<\/h2>\n<p>\nThe table was generated automatically from two test scripts: a bash script (<a href=\"#bash\">compare.sh<\/a>) and a tcsh script (<a href=\"#tcsh\">compare.csh<\/a>). Each one ran all of the commands in the previous table.<\/p>\n<p>I used another script (<a href=\"#genhtml\">genhtml.py<\/a>) to parse them and generate this table automatically under the control of a Makefile. See the comments in the python script for more<br \/>\ndetails about the record format. Here is how I ran it.<\/p>\n<p>[crayon lang=&#8221;bash&#8221; toolbar=&#8221;always&#8221; title=&#8221;script&#8221;]<br \/>\n$ ls -l compare*<br \/>\n-rwxr-xr-x  1 jlinoff  staff   4306 Nov 20 22:03 compare.csh*<br \/>\n-rwxr-xr-x  1 jlinoff  staff   4214 Nov 20 22:04 compare.sh*<br \/>\n$ make<br \/>\numask 0; .\/genhtml.py compare.sh compare.csh >compare.html<br \/>\n[\/crayon]\n<\/p>\n<p>I then manually entered the HTML table data onto this page.<\/p>\n<p><a name=\"make\"><\/a><\/p>\n<h2>Makefile<\/h2>\n<p>\nThis is the make file that I used.\n<\/p>\n<p>[crayon lang=&#8221;make&#8221; toolbar=&#8221;always&#8221; title=&#8221;Makefile&#8221;]<br \/>\n# Generate the bash\/tcsh comparison table.<\/p>\n<p>all: compare.html<\/p>\n<p>clean:<br \/>\n\trm -rf *~ *.html<\/p>\n<p>compare.html: genhtml.py compare.sh compare.csh<br \/>\n\tumask 0; .\/genhtml.py compare.sh compare.csh >$@<br \/>\n[\/crayon]<\/p>\n<p><a name=\"genhtml\"><\/a><\/p>\n<h2>Generate HTML (genhtml.py)<\/h2>\n<p>\nThis is the python script file that generated the HTML table data.\n<\/p>\n<p>[crayon lang=&#8221;python&#8221; toolbar=&#8221;always&#8221; title=&#8221;genhtml.py&#8221;]<br \/>\n#!\/usr\/bin\/env python<br \/>\n&#8221;&#8217;<br \/>\nRead two shell files with specific formatting to parse out<br \/>\ncommon records and produce and HTML table.<\/p>\n<p>It is used to extract the common records from a bash shell script file<br \/>\nand tcsh shell script file.<\/p>\n<p>The idea is to create records in the bash and tcsh files with the same<br \/>\nid so that this script can scoop them up and put them in a table.<\/p>\n<p>Records are surrounded by:<\/p>\n<p>  # BEGIN: <id><br \/>\n  <statements><br \/>\n  # END<\/p>\n<p>The id can be any string but it must be the same in both files.<br \/>\nAnything in between is printed.<\/p>\n<p>THe #@@ token is used to specify non-executing records.<\/p>\n<p>Here is a simple example:<\/p>\n<p>   $ # ================================================================<br \/>\n   $ # bash commands<br \/>\n   $ # ================================================================<br \/>\n   $ cat compare.sh <<EOF\n   #!\/bin\/bash\n\n   # BEGIN: alias\n   alias foo=bar\n   # END\n\n   # BEGIN: array: iterate by item, single line\n   A=(\"a\" \"b\" \"c\")\n   for x in ${A[@]} ; do echo $x; done\n   # END\n\n   # BEGIN: array: iterate by index\n   for i in ${!ARRAY[@]}; do\n       printf \"%d %s\\n\" $i ${ARRAY[i]}\n   done\n   # END\n   EOF\n\n   $ # ================================================================\n   $ # tcsh commands\n   $ # ================================================================\n   $ cat compare.csh <<EOF\n   # BEGIN: alias\n   alias foo bar\n   # END\n\n   # BEGIN: array: iterate by item, single line\n   #@@ N\/A\n   # END\n\n   # BEGIN: array: iterate by index\n   foreach i ( `seq $#ARRAY` )\n       echo $i $ARRAY[$i] |\\\n           awk '{printf(\"%d %s\\n\",$1,$2);}'\n   end\n   # END\n   EOF\n\n   $ # ================================================================\n   $ # Generate the HTML.\n   $ # ================================================================\n   $ .\/genhtml.py compare.sh compare.csh > compare.html<br \/>\n&#8221;&#8217;<br \/>\nimport sys<br \/>\nimport os<br \/>\nimport re<\/p>\n<p># ================================================================<br \/>\n# err<br \/>\n# ================================================================<br \/>\ndef err(msg):<br \/>\n    &#8221;&#8217;<br \/>\n    Print an error message and exit.<br \/>\n    &#8221;&#8217;<br \/>\n    print(&#8216;ERROR: %s&#8217; % (msg))<br \/>\n    sys.exit(1)<\/p>\n<p># ================================================================<br \/>\n# err<br \/>\n# ================================================================<br \/>\ndef parse(fn):<br \/>\n    &#8221;&#8217;<br \/>\n    Parse a shell script file looking for specific format<br \/>\n    instructions in the comments.<br \/>\n    &#8221;&#8217;<br \/>\n    fp = open(fn,&#8217;r&#8217;)<br \/>\n    rows = {}<br \/>\n    row = None<br \/>\n    n=0<br \/>\n    for line in fp.readlines():<br \/>\n        n += 1<br \/>\n        line = line.rstrip()<\/p>\n<p>        # begin<br \/>\n        m = re.search(&#8216;^# BEGIN: (.+)$&#8217;,line)<br \/>\n        if m:<br \/>\n            if row != None:<br \/>\n                err(&#8216;missing END statement around line: %d in %s&#8217; % (n,fn))<\/p>\n<p>            title = m.group(1)<br \/>\n            if title in rows:<br \/>\n                err(&#8216;duplicate entry &#8220;%s&#8221; at line %d in %s&#8217; % (title,n,fn))<\/p>\n<p>            row = {&#8216;title&#8217;:title,<br \/>\n                   &#8216;file&#8217;:fn,<br \/>\n                   &#8216;lineno&#8217;:n,<br \/>\n                   &#8216;lines&#8217;:[],<br \/>\n                   }<br \/>\n            continue<\/p>\n<p>        # end<br \/>\n        m = re.search(&#8216;^# END&#8217;,line)<br \/>\n        if m:<br \/>\n            rows[title]=row<br \/>\n            row = None<br \/>\n            continue<\/p>\n<p>        # between begin and end, everything else is ignored<br \/>\n        if row:<br \/>\n            row[&#8216;lines&#8217;].append(line)<\/p>\n<p>    fp.close()<br \/>\n    return rows<\/p>\n<p># ================================================================<br \/>\n# htmlize<br \/>\n# ================================================================<br \/>\ndef htmlize(line):<br \/>\n    &#8221;&#8217;<br \/>\n    HTMLize a string.<br \/>\n    &#8221;&#8217;<br \/>\n    line = line.replace(&#8216;&#038;&#8217;,&#8217;&amp;&#8217;)<br \/>\n    line = line.replace(&#8216;&#8221;&#8216;,&#8217;&quot;&#8217;)<br \/>\n    line = line.replace(&#8220;&#8216;&#8221;,&#8217;&apos;&#8217;)<br \/>\n    line = line.replace(&#8216;<','&lt;')\n    line = line.replace('>&#8216;,&#8217;&gt;&#8217;)<br \/>\n    line = line.replace(&#8216; &#8216;,&#8217;&nbsp;&#8216;)<br \/>\n    line = line.replace(&#8216;`&#8217;,&#8217;&#96;&#8217;)<br \/>\n    line = line.replace(&#8216;-&#8216;,&#8217;&ndash;&#8217;)<br \/>\n    return line<\/p>\n<p># ================================================================<br \/>\n# myprint<br \/>\n# ================================================================<br \/>\ndef myprint(m):<br \/>\n    &#8221;&#8217;<br \/>\n    Write a string to stdout.<br \/>\n    &#8221;&#8217;<br \/>\n    sys.stdout.write(str(m))<\/p>\n<p># ================================================================<br \/>\n# cell<br \/>\n# ================================================================<br \/>\ndef cell(indent, rec):<br \/>\n    &#8221;&#8217;<br \/>\n    Write out a column cell.<br \/>\n    &#8221;&#8217;<br \/>\n    myprint(&#8216;%s<\/p>\n<td class=\"mycell-code\">&#8216; % (indent))<br \/>\n    first=True<br \/>\n    for line in rec[&#8216;lines&#8217;]:<br \/>\n        if not first:<br \/>\n            myprint(&#8216;<br \/>&#8216;)<br \/>\n        first = False<br \/>\n        line = line.replace(&#8216;#@@ &#8216;,&#8221;)<br \/>\n        myprint(htmlize(line))<\/p>\n<p>    myprint(&#8216;<\/td>\n<p>\\n&#8217;)<\/p>\n<p># ================================================================<br \/>\n# gencss<br \/>\n# ================================================================<br \/>\ndef gencss():<br \/>\n    &#8221;&#8217;<br \/>\n    Generate the CSS styling information specifically for<br \/>\n    wordpress.<br \/>\n    &#8221;&#8217;<\/p>\n<p>    css =&#8221;&#8217;<\/p>\n<style type=\"text\/css\">\n      table.mytable {\n        font-family: Arial, Helvetica; \n        font-size: 1.2em;\n        border-collapse: separate;\n        border-spacing: 1px;\n        *border-collapse: expression('separate', cellSpacing = '1px');\n        border: 2px solid lightgray;\n      }\n      tr.myrow-even {\n        vertical-align: top;\n        background-color: #ffffea;\n        border: 2px solid lightgray;\n      }\n      tr.myrow-odd {\n        vertical-align: top;\n        background-color: none;\n        border: 2px solid lightgray;\n      }\n      th.mycell-hdr {\n        vertical-align: top;\n        text-align: center;\n        padding: 4px 4px;\n        border: 2px solid lightgray;\n        \/*font-size: 1.3em;*\/\n      }\n      td.mycell-id {\n        vertical-align: top;\n        text-align: right;\n        padding: 2px 2px;\n        border: 1px solid lightgray;\n        font-size: 0.9em;\n        line-height: 100%;\n      }\n      td.mycell-title {\n        vertical-align: top;\n        text-align: left;\n        padding: 2px 2px;\n        border: 1px solid lightgray;\n        font-size: 0.9em;\n        line-height: 100%;\n      }\n      td.mycell-code {\n        vertical-align: top;\n        font-family: \"Courier New\", monospace; \n        text-align: left;\n        padding: 2px 2px;\n        border: 1px solid lightgray;\n        font-size: 0.9em;\n        line-height: 100%;\n      }\n      div#mydiv {\n        margin-left: -30px;\n        width: 110%;\n      }\n    <\/style>\n<p> &#8221;&#8217;<br \/>\n    return css<\/p>\n<p># ================================================================<br \/>\n# main<br \/>\n# ================================================================<br \/>\ndef main():<br \/>\n    &#8221;&#8217;<br \/>\n    Main entry point.<br \/>\n    &#8221;&#8217;<br \/>\n    # This is a simple script, no need for fancy argument handling.<br \/>\n    assert len(sys.argv) == 3<\/p>\n<p>    bash_shell = sys.argv[1]<br \/>\n    tcsh_shell = sys.argv[2]<\/p>\n<p>    bash_recs = parse(bash_shell)<br \/>\n    tcsh_recs = parse(tcsh_shell)<\/p>\n<p>    if len(bash_recs) != len(tcsh_recs):<br \/>\n        err(&#8216;Mismatched number of records: %d != %d&#8217; % (len(bash_recs),<br \/>\n                                                        len(tcsh_recs)))<\/p>\n<p>    for title in sorted(bash_recs):<br \/>\n        if title not in tcsh_recs:<br \/>\n            err(&#8216;missing entry &#8220;%s&#8221;&#8216; % (title))<\/p>\n<p>    myprint(gencss())<br \/>\n    print &#8221;&#8217;<\/p>\n<div id=\"mydiv\">\n<table>\n<thead>\n<tr bgcolor=\"#DDDDDD\">\n<th class=\"mycell-hdr\">ID<\/th>\n<th class=\"mycell-hdr\">Operation<\/th>\n<th class=\"mycell-hdr\">bash<\/th>\n<th class=\"mycell-hdr\">tcsh<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n&#8221;&#8217;<br \/>\n    tr_indent = &#8216;          &#8216;<br \/>\n    td_indent = tr_indent + &#8216;  &#8216;<br \/>\n    i=0<br \/>\n    for title in sorted(bash_recs, key=lambda x: x.lower()):<br \/>\n        bash_rec=bash_recs[title]<br \/>\n        tcsh_rec=tcsh_recs[title]<\/p>\n<p>        if (i%2) == 0:<br \/>\n            myprint(&#8216;%s<\/p>\n<tr class=\"myrow-even\">\\n&#8217; % (tr_indent))<br \/>\n        else:<br \/>\n            myprint(&#8216;%s<\/p>\n<tr class=\"myrow-odd\">\\n&#8217; % (tr_indent))<br \/>\n        myprint(&#8216;%s<\/p>\n<td class=\"mycell-id\">%d<\/td>\n<p>\\n&#8217; % (td_indent, i+1))<br \/>\n        myprint(&#8216;%s<\/p>\n<td class=\"mycell-title\">%s<\/td>\n<p>\\n&#8217; % (td_indent, title))<br \/>\n        cell(td_indent, bash_rec)<br \/>\n        cell(td_indent, tcsh_rec)<br \/>\n        myprint(&#8216;%s<\/tr>\n<p>\\n&#8217; % (tr_indent))<br \/>\n        i += 1<\/p>\n<p>    print &#8221;&#8217;<br \/>\n        <\/tbody>\n<\/table><\/div>\n<p>&#8221;&#8217;<\/p>\n<p>if __name__ == &#8216;__main__&#8217;:<br \/>\n    main()<br \/>\n[\/crayon]<\/p>\n<p><a name=\"bash\"><\/a><\/p>\n<h2>Bash Commands Script (compare.sh)<\/h2>\n<p>\nThis is the script that tested the bash commands.\n<\/p>\n<p>[crayon lang=&#8221;bash&#8221; toolbar=&#8221;always&#8221; title=&#8221;compare.sh&#8221;]<br \/>\n#!\/bin\/bash<\/p>\n<p># BEGIN: alias<br \/>\nalias foo=bar<br \/>\n# END<\/p>\n<p># BEGIN: array: declaration<br \/>\nARRAY=(&#8220;a&#8221; &#8220;b&#8221; &#8220;c&#8221;)<br \/>\n# END<\/p>\n<p># BEGIN: array: size<br \/>\necho ${#ARRAY[@]} items<br \/>\n# END<\/p>\n<p># BEGIN: array: first item<br \/>\necho first item [0] = ${ARRAY[0]}<br \/>\n# END<\/p>\n<p># BEGIN: array: iterate by item<br \/>\nfor item in ${ARRAY[@]} ; do<br \/>\n    echo item = $item<br \/>\ndone<br \/>\n# END<\/p>\n<p># BEGIN: array: iterate by item, single line<br \/>\nA=(&#8220;a&#8221; &#8220;b&#8221; &#8220;c&#8221;)<br \/>\nfor x in ${A[@]} ; do echo $x; done<br \/>\n# END<\/p>\n<p># BEGIN: array: iterate by index<br \/>\nfor i in ${!ARRAY[@]}; do<br \/>\n    printf &#8220;%d %s\\n&#8221; $i ${ARRAY[i]}<br \/>\ndone<br \/>\n# END<\/p>\n<p># BEGIN: variable: create scalar<br \/>\ni=0<br \/>\ns=&#8221;foo bar spam&#8221;<br \/>\n# END<\/p>\n<p># BEGIN: variable: create array<br \/>\nARRAY=(&#8220;item1&#8221; &#8220;item2&#8221; &#8220;item2&#8221;)<br \/>\n# END<\/p>\n<p># BEGIN: variable: destroy or unset<br \/>\nARRAY=(&#8220;item1&#8221; &#8220;item2&#8221; &#8220;item2&#8221;)<br \/>\nunset ARRAY<br \/>\n# END<\/p>\n<p># BEGIN: variable: auto increment<br \/>\ni=0<br \/>\n(( i++ ))<br \/>\necho auto increment = $i<br \/>\n# END<\/p>\n<p># BEGIN: variable: auto decrement<br \/>\ni=0<br \/>\n(( i&#8211; ))<br \/>\necho auto deccrement = $i<br \/>\n# END<\/p>\n<p># BEGIN: function<br \/>\nfunction echo-cmds {<br \/>\n    echo &#8220;CMD : &#8220;$*<br \/>\n    # Echo the commands.<br \/>\n    local args=&#8221;$@&#8221; # local var<br \/>\n    $args | sed -e &#8216;s\/^\/      \/&#8217;<br \/>\n}<br \/>\necho-cmds pwd<br \/>\necho-cmds ls -l<br \/>\n# END<\/p>\n<p># BEGIN: job: start in the background<br \/>\n#@@ job &#038;<br \/>\n# END<\/p>\n<p># BEGIN: job: move into the background<br \/>\n#@@ job<br \/>\n#@@ <Ctrl-Z><br \/>\n#@@ bg<br \/>\n# END<\/p>\n<p># BEGIN: job: status<br \/>\n#@@ job<br \/>\n#@@ echo status = $?<br \/>\n# END<\/p>\n<p># BEGIN: variable: debug tracing<br \/>\nset -x # on<br \/>\npwd<br \/>\nset +x # off<br \/>\npwd<br \/>\n# END<\/p>\n<p># BEGIN: variable: dump state<br \/>\nset<br \/>\n# END<\/p>\n<p># BEGIN: variable: turn on unset variable checking<br \/>\nset -u<br \/>\n# END<br \/>\nset +u<\/p>\n<p># BEGIN: variable: automatically exit on error<br \/>\n#@@ \/bin\/bash -e # invocation<br \/>\nset -e # inside the shell<br \/>\n# END<br \/>\nset +e<\/p>\n<p># BEGIN: variable: print environment variables<br \/>\nenv<br \/>\nprintenv<br \/>\n# END<\/p>\n<p># BEGIN: variable: dynamic<br \/>\n# Native support, can also use eval.<br \/>\na=&#8221;some value&#8221;<br \/>\nb=a<br \/>\necho $b = ${!b}<br \/>\nbv=&#8221;${!b}&#8221;<br \/>\necho bv = $bv<br \/>\n# END<\/p>\n<p># BEGIN: IO: redirect stdout<br \/>\nls > \/tmp\/$$<br \/>\n# END<\/p>\n<p># BEGIN: IO: redirect stderr<br \/>\nls 2> \/tmp\/$$<br \/>\n# END<\/p>\n<p># BEGIN: IO: redirect stdout and stderr<br \/>\nls > \/tmp\/$$ 2>&#038;1 # older<br \/>\nls &#038;> \/tmp\/$$     # newer<br \/>\n# END<\/p>\n<p># BEGIN: exit the shell<br \/>\n#@@ exit<br \/>\n#@@ exit 1<br \/>\n# END<\/p>\n<p># BEGIN: job: move into the foreground<br \/>\n#@@ fg<br \/>\n#@@ fg %1<br \/>\n# END<\/p>\n<p># BEGIN: formatted printing<br \/>\n# Native support.<br \/>\nprintf &#8220;%05d %s\\n&#8221; 42 &#8220;Deep Thought&#8221;<br \/>\n# END<\/p>\n<p># BEGIN: if\/then\/else: numeric<br \/>\ni=2<br \/>\nif (( i>2 )) ; then<br \/>\n    echo i greater than 2<br \/>\nelif (( i<2 )) ; then\n    echo i less than 2\nelse\n    echo i is two\nfi\n# END\n\n# BEGIN: if\/then\/else: string\ns=\"foo bar\"\nif [[ \"$s\" == \"foo bar\" ]] ; then\n    echo \"foo\"\nelse\n    echo \"spam\"\nfi\n# END\n\n# BEGIN: include a file\n#@@ source include-file\n#@@ .  include-file\n# END\n\n# BEGIN: set resource limits\n#@@ ulimit\n# END\n\n# BEGIN: set path variable\nexport PATH=\"$PATH:\/tmp\"\n# END\n\n# BEGIN: get shell name\necho $SHELL\n# END\n\n# BEGIN: get shell version\nbash --version\necho $BASH_VERSION\n# END\n\n# BEGIN: switch statement\narg=\"foo\"\ncase \"$arg\" in\n    \"foo\")\n        echo \"do foo\"\n        ;;\n    \"bar\")\n        echo \"do bar\"\n        ;;\n    \"spam\")\n        echo \"do spam\"\n        ;;\n    *)\n        echo \"do be do be do\"\n        ;;\nesac\n# END\n\n# BEGIN: read values from the console\nread -p \"login? \" login\nread -p \"passwd? \" -s passwd\necho\necho \"login: $login\"\necho \"passwd: $passwd\"\n# END\n\n\n# BEGIN: prompt\nset PS1='\\u >&#8216;  # user name<br \/>\nset PS1=&#8217;\\h >&#8217;  # host<br \/>\nset PS1=&#8217;\\! >&#8217;  # command num<br \/>\n#set PS1=N\/A >&#8217; # last 3 dir parts<br \/>\nset PS1=&#8217;\\W >&#8217;  # last dir part<br \/>\nset PS1=&#8217;\\w >&#8217;  # curr dir full<br \/>\nset PS1=&#8217;\\v >&#8217;  # shell version<br \/>\nset PS1=&#8217;\\u@\\h \\W (\\!) >&#8217;<br \/>\n# END<\/p>\n<p># BEGIN: regex extension check<br \/>\nFILES=(&#8216;f1.tar.bz2&#8217; &#8216;f2.tar.gz&#8217; &#8216;f3.zip&#8217;)<br \/>\nfor FILE in ${FILES[@]} ; do<br \/>\n    if [[ &#8220;$FILE&#8221; =~ .tar.bz2$ ]] ; then<br \/>\n        echo &#8220;tar.bz2: $FILE&#8221;<br \/>\n    elif [[ &#8220;$FILE&#8221; =~ .tar.gz$ ]] ; then<br \/>\n        echo &#8220;tar.gz: $FILE&#8221;<br \/>\n    elif [[ &#8220;$FILE&#8221; =~ .zip$ ]] ; then<br \/>\n        echo &#8220;zip: $FILE&#8221;<br \/>\n    else<br \/>\n        echo &#8220;unk: $FILE&#8221;<br \/>\n    fi<br \/>\ndone<br \/>\n# END<\/p>\n<p># BEGIN: command substitution<br \/>\n# style 1 &#8211; can&#8217;t be nested<br \/>\nx=`ls -1`<br \/>\n# style 2 &#8211; can be nested<br \/>\nme=$(dirname &#8212; $(readlink -f .))<br \/>\necho $me<br \/>\n# END<\/p>\n<p># BEGIN: local variable<br \/>\nfunction fct {<br \/>\n    local var=&#8217;local&#8217;<br \/>\n}<br \/>\n# END<\/p>\n<p># BEGIN: range iteration<br \/>\nfor i in `seq 1000` ; do<br \/>\n    echo $i<br \/>\ndone<\/p>\n<p>for i in $( seq 1000 ) ; do<br \/>\n    echo $i<br \/>\ndone<\/p>\n<p># fastest<br \/>\nfor i in {1..1000} ; do<br \/>\n    echo $i<br \/>\ndone<br \/>\n# END<\/p>\n<p># BEGIN: setenv\/export<br \/>\nexport FOOBAR=&#8221;spam&#8221;<br \/>\n# END<\/p>\n<p># BEGIN: variable: substitution<br \/>\nfoo=&#8217;bar&#8217;<br \/>\necho ${foo\/bar\/baz\/}<br \/>\n# END<br \/>\n[\/crayon]<\/p>\n<p><a name=\"tcsh\"><\/a><\/p>\n<h2>Tcsh Commands Script (compare.csh)<\/h2>\n<p>\nThis is the script that tested the tcsh commands.\n<\/p>\n<p>[crayon lang=&#8221;tcsh&#8221; toolbar=&#8221;always&#8221; title=&#8221;compare.ch&#8221;]<br \/>\n#!\/bin\/tcsh<\/p>\n<p># BEGIN: alias<br \/>\nalias foo bar<br \/>\n# END<\/p>\n<p># BEGIN: array: declaration<br \/>\nset ARRAY = (&#8220;a&#8221; &#8220;b&#8221; &#8220;c&#8221;)<br \/>\n# END<\/p>\n<p># BEGIN: array: size<br \/>\necho $#ARRAY items<br \/>\n# END<\/p>\n<p># BEGIN: array: first item<br \/>\necho &#8220;first item [1] = $ARRAY[1]&#8221;<br \/>\n# END<\/p>\n<p># BEGIN: array: iterate by item<br \/>\nforeach item ( $ARRAY )<br \/>\n    echo item = $item<br \/>\nend<br \/>\n# END<\/p>\n<p># BEGIN: array: iterate by item, single line<br \/>\n#@@ N\/A<br \/>\n# END<\/p>\n<p># BEGIN: array: iterate by index<br \/>\nforeach i ( `seq $#ARRAY` )<br \/>\n    echo $i $ARRAY[$i] |\\<br \/>\n        awk &#8216;{printf(&#8220;%d %s\\n&#8221;,$1,$2);}&#8217;<br \/>\nend<br \/>\n# END<\/p>\n<p># BEGIN: variable: create scalar<br \/>\nset i=0<br \/>\nset=&#8221;foo bar spam&#8221;<br \/>\n# END<\/p>\n<p># BEGIN: variable: create array<br \/>\nset ARRAY=(&#8220;item1&#8221; &#8220;item2&#8221; &#8220;item2&#8221;)<br \/>\n# END<\/p>\n<p># BEGIN: variable: destroy or unset<br \/>\nset ARRAY=(&#8220;item1&#8221; &#8220;item2&#8221; &#8220;item2&#8221;)<br \/>\nunset ARRAY<br \/>\n# END<\/p>\n<p># BEGIN: variable: auto increment<br \/>\nset i=0<br \/>\n@ i++<br \/>\necho auto increment = $i<br \/>\n# END<\/p>\n<p># BEGIN: variable: auto decrement<br \/>\nset i=0<br \/>\n@ i&#8211;<br \/>\necho auto decrement = $i<br \/>\n# END<\/p>\n<p># BEGIN: function<br \/>\n#@@ N\/A<br \/>\n#@@ Can be emulated using<br \/>\n#@@ external scripts<br \/>\n# END<\/p>\n<p># BEGIN: job: start in the background<br \/>\n#@@ job &#038;<br \/>\n# END<\/p>\n<p># BEGIN: job: move into the background<br \/>\n#@@ job<br \/>\n#@@ <Ctrl-Z><br \/>\n#@@ bg<br \/>\n# END<\/p>\n<p># BEGIN: job: move into the foreground<br \/>\n#@@ fg<br \/>\n#@@ fg %1<br \/>\n# END<\/p>\n<p># BEGIN: job: status<br \/>\n#@@ job<br \/>\n#@@ echo status = $?<br \/>\n# END<\/p>\n<p># BEGIN: variable: debug tracing<br \/>\nset verbose # on<br \/>\npwd<br \/>\nunset verbose # off<br \/>\npwd<br \/>\n# END<\/p>\n<p># BEGIN: variable: dump state<br \/>\nset<br \/>\n# END<\/p>\n<p># BEGIN: variable: turn on unset variable checking<br \/>\n#@@ N\/A<br \/>\n# END<\/p>\n<p># BEGIN: variable: automatically exit on error<br \/>\n#@@ \/bin\/tcsh -e # invocation only<br \/>\n# END<\/p>\n<p># BEGIN: variable: print environment variables<br \/>\nenv<br \/>\nprintenv<br \/>\n# END<\/p>\n<p># BEGIN: variable: dynamic<br \/>\n# Not native, need to use eval.<br \/>\nset a=&#8221;some value&#8221;<br \/>\nset b=&#8221;a&#8221;<br \/>\neval &#8220;echo $b = &#8220;&#8216;$&#8217;${b}<br \/>\nset bv=`eval echo &#8216;$&#8217;$b`<br \/>\necho bv = $bv<br \/>\n# END<\/p>\n<p># BEGIN: IO: redirect stdout<br \/>\nls > \/tmp\/$$<br \/>\n# END<\/p>\n<p># BEGIN: IO: redirect stderr<br \/>\n( ls > \/dev\/tty ) >&#038; \/tmp\/$$<br \/>\n# END<\/p>\n<p># BEGIN: IO: redirect stdout and stderr<br \/>\nls >&#038; \/tmp\/$$<br \/>\n# END<\/p>\n<p># BEGIN: exit the shell<br \/>\n#@@ exit<br \/>\n#@@ exit 1<br \/>\n# END<\/p>\n<p># BEGIN: formatted printing<br \/>\n# No native support,<br \/>\n# emulate with awk.<br \/>\n# Embedded spaces are a pain.<br \/>\necho 42 &#8220;Deep Thought&#8221; |\\<br \/>\n  awk &#8216;{printf(&#8220;%05d %s %s\\n&#8221;,$1,$2,$3);&#8217;}<br \/>\n# END<\/p>\n<p># BEGIN: if\/then\/else: numeric<br \/>\nset i=2<br \/>\nif ($i>2) then<br \/>\n    echo i greater than 2<br \/>\nelse if ($i<2) then\n    echo i less than 2\nelse\n    echo i is two\nendif\n# END\n\n# BEGIN: if\/then\/else: string\nset s=\"foo bar\"\nif (\"$s\" == \"foo bar\") then\n    echo \"foo\"\nelse\n    echo \"spam\"\nendif\n# END\n\n# BEGIN: include a file\n#@@ source include-file\n# END\n\n# BEGIN: set resource limits\n#@@ limit\n# END\n\n# BEGIN: set path variable\nset path = ( $path \/tmp )\n# END\n\n# BEGIN: get shell name\necho $shell\n# END\n\n# BEGIN: get shell version\ntcsh --version\necho $version\n# END\n\n# BEGIN: switch statement\nset arg=\"foo\"\nswitch (\"$arg\")\n    case \"foo\":\n        echo \"do foo\"\n        breaksw\n    case \"bar\":\n        echo \"do bar\"\n        breaksw\n    case \"spam\":\n        echo \"do spam\"\n        breaksw\n    default:\n        echo \"do be do be do\"\n        breaksw\nendsw\n# END\n\n# BEGIN: read values from the console\necho -n \"login? \"\nset login = $<\n\necho -n \"passwd? \"\nstty -echo\nset passwd = $<\nstty echo\n\necho\necho \"login: $login\"\necho \"passwd: $passwd\"\n# END\n\n# BEGIN: prompt\nset prompt='%n >&#8216;  # user name<br \/>\nset prompt=&#8217;%j >&#8217;  # host<br \/>\nset prompt=&#8217;! >&#8217;   # command num<br \/>\nset prompt=&#8217;%c3 >&#8217; # last 3 dir parts<br \/>\nset prompt=&#8217;%c >&#8217;  # last dir part<br \/>\nset prompt=&#8217;%~ >&#8217;  # curr dir full<br \/>\n#set prompt=N\/A    # shell version<br \/>\nset prompt=&#8217;%n@%j %c (!) >&#8217;<br \/>\n# END<\/p>\n<p># BEGIN: regex extension check<br \/>\nset FILES=(&#8216;f1.tar.bz2&#8217; &#8216;f2.tar.gz&#8217; &#8216;f3.zip&#8217;)<br \/>\nforeach FILE ( $FILES )<br \/>\n    echo $FILE | grep &#8216;.tar.bz2$&#8217; >&#038;\/dev\/null<br \/>\n    if ( $? == 0 ) then<br \/>\n        echo &#8220;tar.bz2: $FILE&#8221;<br \/>\n        continue<br \/>\n    endif<\/p>\n<p>    echo $FILE | grep &#8216;.tar.gz$&#8217; >&#038;\/dev\/null<br \/>\n    if ( $? == 0 ) then<br \/>\n        echo &#8220;tar.gz: $FILE&#8221;<br \/>\n        continue<br \/>\n    endif<\/p>\n<p>    echo $FILE | grep &#8216;.zip$&#8217; >&#038;\/dev\/null<br \/>\n    if ( $? == 0 ) then<br \/>\n        echo &#8220;zip: $FILE&#8221;<br \/>\n        continue<br \/>\n    endif<\/p>\n<p>    echo &#8220;unk: $FILE&#8221;<br \/>\nend<br \/>\n# END<\/p>\n<p># BEGIN: command substitution<br \/>\n# style 1 &#8211; can&#8217;t be nested<br \/>\nset x = `ls -1`<br \/>\n# style 2 &#8211; not supported<br \/>\nset r = `readlink -f .`<br \/>\nset me = `dirname $r`<br \/>\necho $me<br \/>\n# END<\/p>\n<p># BEGIN: local variable<br \/>\n# functions not supported<br \/>\n# END<\/p>\n<p># BEGIN: range iteration<br \/>\nforeach i ( `seq 1000` )<br \/>\n  echo $i<br \/>\nend<br \/>\n# END<\/p>\n<p># BEGIN: setenv\/export<br \/>\nsetenv FOOBAR &#8220;spam&#8221;<br \/>\n# END<\/p>\n<p># BEGIN: variable: substitution<br \/>\nset foo = &#8216;bar&#8217;<br \/>\necho $foo:s\/bar\/baz\/<br \/>\n# END<br \/>\n[\/crayon]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents Bash\/Tcsh Comparison Table How It Was Generated Makefile Generate HTML (genhtml.py) Bash Commands Script (compare.sh) Tcsh Commands Script (compare.csh) Bash\/Tcsh Comparison Table The table below shows bash commands and their equivalents in tcsh along with the tools that I wrote to create it. I put it together because I sometimes have to &hellip; <a href=\"https:\/\/joelinoff.com\/blog\/?page_id=235\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Translate between bash and tcsh commands<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"_links":{"self":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/pages\/235"}],"collection":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=235"}],"version-history":[{"count":84,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/pages\/235\/revisions"}],"predecessor-version":[{"id":1188,"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=\/wp\/v2\/pages\/235\/revisions\/1188"}],"wp:attachment":[{"href":"https:\/\/joelinoff.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}