{"id":1250,"date":"2023-01-05T11:17:43","date_gmt":"2023-01-05T11:17:43","guid":{"rendered":"https:\/\/jamj.org\/?p=1250"},"modified":"2023-01-05T11:17:43","modified_gmt":"2023-01-05T11:17:43","slug":"bash-command","status":"publish","type":"post","link":"https:\/\/jamj.org\/index.php\/2023\/01\/05\/bash-command\/","title":{"rendered":"The !! bash command"},"content":{"rendered":"\n<p>There is a not very well known bash command that allows you to repeat the last input  you typed in the shell. Behold the <strong><em>&#8220;!!&#8221;<\/em><\/strong> command. This simply allows us to retype the last input.  For instance: <\/p>\n\n\n\n<p>If I type: (to list files in the local directory): <\/p>\n\n\n\n<p><code>ls -lh<\/code><\/p>\n\n\n\n<p>and after that I type: <\/p>\n\n\n\n<p><code>!!<\/code><\/p>\n\n\n\n<p>It will repeat the <strong><em>&#8220;ls -lh&#8221;<\/em><\/strong> command.<\/p>\n\n\n\n<p>This comes in handy when you want to script bash in a file. You can also add regex expressions. Imagine you forgot to include the hidden files in your listing, you can replace <strong><em>&#8220;lh&#8221;<\/em><\/strong> with <strong><em>&#8220;lha&#8221;<\/em><\/strong><\/p>\n\n\n\n<p><code>!!:s\/lh\/lha<\/code><\/p>\n\n\n\n<p>As always, feel free to experiment. And do not forget to check the documentation. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a not very well known bash command that allows you to repeat the last input you typed in the shell. Behold the &#8220;!!&#8221; command. This simply allows us to retype the last input. For instance: If I type: (to list files in the local directory): ls -lh and after that I type: !! [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1250","post","type-post","status-publish","format-standard","hentry","category-gnu"],"_links":{"self":[{"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/posts\/1250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/comments?post=1250"}],"version-history":[{"count":0,"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/posts\/1250\/revisions"}],"wp:attachment":[{"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/media?parent=1250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/categories?post=1250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jamj.org\/index.php\/wp-json\/wp\/v2\/tags?post=1250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}