{"id":3352,"date":"2014-09-06T20:30:50","date_gmt":"2014-09-06T20:30:50","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3352"},"modified":"2014-09-06T20:35:10","modified_gmt":"2014-09-06T20:35:10","slug":"bash-scripting-how-to-get-a-files-name-without-its-extensions","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/bash-scripting-how-to-get-a-files-name-without-its-extensions\/","title":{"rendered":"[bash scripting] How to get a file&#8217;s name without its extension(s)."},"content":{"rendered":"<p>Say you have an encrypted file <strong>file.foo.gpg<\/strong> and you want to make a shorthand command to decrypt that file, you&#8217;ll want the resulting file to be named file.foo (without the .gpg), or say you want the name, with no extension?), you can use bash&#8217;s magic variable voodo for that.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3353\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-06-at-4.29.38-PM.png?resize=625%2C177\" alt=\"Screen Shot 2014-09-06 at 4.29.38 PM\" width=\"625\" height=\"177\" \/><\/p>\n<p>A simple version of that script would look something like this:<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3356\" src=\"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-06-at-4.34.26-PM.png?resize=442%2C115\" alt=\"Screen Shot 2014-09-06 at 4.34.26 PM\" width=\"442\" height=\"115\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Say you have an encrypted file file.foo.gpg and you want to make a shorthand command to decrypt that file, you&#8217;ll want the resulting file to be named file.foo (without the .gpg), or say you want the name, with no extension?), you can use bash&#8217;s magic variable voodo for that. A simple version of that script [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15,43],"tags":[183,1415,1416,1000],"class_list":["post-3352","post","type-post","status-publish","format-standard","hentry","category-code","category-linux","tag-bash","tag-bash-scripting","tag-scripting","tag-tips"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-S4","jetpack-related-posts":[{"id":3821,"url":"https:\/\/www.gubatron.com\/blog\/bash-scripting-contains_item-bash-function-check-if-an-item-is-in-an-array\/","url_meta":{"origin":3352,"position":0},"title":"[bash scripting] `contains_item` bash function. Check if an item is in an array","author":"gubatron","date":"September 6, 2019","format":false,"excerpt":"","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":516,"url":"https:\/\/www.gubatron.com\/blog\/ejemplo-de-automatizacion-entre-2-maquinas-remotas-con-bash-scripting-y-python\/","url_meta":{"origin":3352,"position":1},"title":"Ejemplo de automatizacion entre 2 maquinas remotas con bash scripting y Python","author":"gubatron","date":"May 10, 2007","format":false,"excerpt":"Para los amigos que se inician en el mundo *nix, ya sea con su nueva Mac, o con una PC corriendo Linux, les recomiendo que aprendan a manejar bien los siguientes lenguajes, y el mundo sera suyo: - bash scripting (aliases, variables, exports, iteraciones, condicionales) - python (para programar logica\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1998,"url":"https:\/\/www.gubatron.com\/blog\/startkeychain-bash-utility-to-start-ssh-agent\/","url_meta":{"origin":3352,"position":2},"title":"startKeychain &#8211; bash utility to start ssh-agent","author":"gubatron","date":"June 3, 2010","format":false,"excerpt":"For my (and your) future reference, here's a function to put on your .bashrc or .bash_profile, you can invoke it later at any time to start\/re-start your ssh-agent. [bash] function startKeychain { killall ssh-agent rm ~\/.keychain\/* keychain id_rsa HOSTNAME=`hostname` source ~\/.keychain\/${HOSTNAME}-sh } [\/bash] Then at any time, the \"command\" startKeychain\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1939,"url":"https:\/\/www.gubatron.com\/blog\/solved-eclipse-cant-see-my-android-device-on-ubuntu\/","url_meta":{"origin":3352,"position":3},"title":"[SOLVED] Eclipse can&#8217;t see my Android Device on Ubuntu","author":"gubatron","date":"May 28, 2010","format":false,"excerpt":"Are you seeing this on eclipse when you plug your Android device to your Ubuntu box? Serial Number: ?????????? AVD Name: N\/A Target: unknown State: ?? Here's the solution: 1. Create a script to fix this next time it happens, let's call it \"android_device_reset\" and save it on a folder\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3793,"url":"https:\/\/www.gubatron.com\/blog\/solving-received-fatal-alert-handshake_failure-error-when-performing-https-connections-on-a-custom-made-jre-with-jlink\/","url_meta":{"origin":3352,"position":4},"title":"Solving &#8220;Received fatal alert: handshake_failure&#8221; error when performing HTTPS connections on a custom made JRE with jlink","author":"gubatron","date":"April 25, 2019","format":false,"excerpt":"TL; Tell me already what to do: Add the jdk.crypto.cryptoki module to the list of --add-modules parameter to your jlink command invocation If you're reading this you're one of the few developers out there that wanted to distribute a java 9+ app (using either jdk 9, jdk 10, jdk 11\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/04\/dragon.jpg?fit=1200%2C797&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/04\/dragon.jpg?fit=1200%2C797&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/04\/dragon.jpg?fit=1200%2C797&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/04\/dragon.jpg?fit=1200%2C797&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2019\/04\/dragon.jpg?fit=1200%2C797&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":570,"url":"https:\/\/www.gubatron.com\/blog\/check-if-your-phps-diff-syntax-isnt-breaking\/","url_meta":{"origin":3352,"position":5},"title":"Check if your PHP&#8217;s diff syntax isn&#8217;t breaking","author":"gubatron","date":"August 11, 2007","format":false,"excerpt":"Say you're working on emacs, without any kind of syntax checking, and you don't want to commit your code cause you might have syntax errors. If you're smart, the best way to know what files you actually changed, is using svn diff | grep +++ (that is, if you're using\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=3352"}],"version-history":[{"count":3,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3352\/revisions"}],"predecessor-version":[{"id":3357,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3352\/revisions\/3357"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}