{"id":3821,"date":"2019-09-06T02:49:44","date_gmt":"2019-09-06T02:49:44","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3821"},"modified":"2019-09-06T02:54:00","modified_gmt":"2019-09-06T02:54:00","slug":"bash-scripting-contains_item-bash-function-check-if-an-item-is-in-an-array","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/bash-scripting-contains_item-bash-function-check-if-an-item-is-in-an-array\/","title":{"rendered":"[bash scripting] `contains_item` bash function. Check if an item is in an array"},"content":{"rendered":"<p><script src=\"https:\/\/gist.github.com\/gubatron\/86848574b332d0f7ef9cfc805de64b37.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[15,43,45],"tags":[183,1415,1449,1610,1153,810,1367],"class_list":["post-3821","post","type-post","status-publish","format-standard","hentry","category-code","category-linux","category-mac-osx","tag-bash","tag-bash-scripting","tag-linux","tag-nix","tag-posix","tag-programming","tag-unix"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-ZD","jetpack-related-posts":[{"id":3352,"url":"https:\/\/www.gubatron.com\/blog\/bash-scripting-how-to-get-a-files-name-without-its-extensions\/","url_meta":{"origin":3821,"position":0},"title":"[bash scripting] How to get a file&#8217;s name without its extension(s).","author":"gubatron","date":"September 6, 2014","format":false,"excerpt":"Say you have an encrypted file file.foo.gpg and you want to make a shorthand command to decrypt that file, you'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's magic variable voodo for that. A\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"Screen Shot 2014-09-06 at 4.29.38 PM","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=350%2C200","width":350,"height":200,"srcset":"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=350%2C200 1x, 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=525%2C300 1.5x"},"classes":[]},{"id":1998,"url":"https:\/\/www.gubatron.com\/blog\/startkeychain-bash-utility-to-start-ssh-agent\/","url_meta":{"origin":3821,"position":1},"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":2751,"url":"https:\/\/www.gubatron.com\/blog\/ubuntudebian-abort-error-_ssl-c504-error14090086ssl-fixed\/","url_meta":{"origin":3821,"position":2},"title":"ubuntu\/debian abort: error: _ssl.c:504: error:14090086:SSL [FIXED]","author":"gubatron","date":"July 3, 2012","format":false,"excerpt":"Trying to clone or update a repo, and you get this error? [bash] hg pull -u abort: error: _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed [\/bash] Quick fix, go to .hgrc and put this on your [web] section [bash] [web] cacerts= [\/bash] Fixed, remember to leave a tip if you wasted hours\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":3821,"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":2202,"url":"https:\/\/www.gubatron.com\/blog\/have-the-latest-haproxy-as-a-ubuntu-service\/","url_meta":{"origin":3821,"position":4},"title":"Have the latest HAProxy as a Ubuntu Service","author":"gubatron","date":"April 6, 2011","format":false,"excerpt":"So you need to use HAProxy and you love the convenience of binary packages on repos, but when you install the version HAProxy available in the repos you realize that it is way too old for what you need. Then you download the latest HAProxy, compile it, configure it, but\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":814,"url":"https:\/\/www.gubatron.com\/blog\/how-to-banunban-ips-in-linux\/","url_meta":{"origin":3821,"position":5},"title":"How to ban\/unban ips in linux","author":"gubatron","date":"May 29, 2008","format":false,"excerpt":"In case you're not an iptables guru, you might want to create a couple scripts and put em somewhere on your $PATH. I've created two scripts called ban_ip and unban_ip. Create a file called ban_ip touch ban_ip chmod +x ban_ip Edit it and copy the following code inside: #!\/bin\/bash sudo\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\/3821","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=3821"}],"version-history":[{"count":5,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3821\/revisions"}],"predecessor-version":[{"id":3826,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3821\/revisions\/3826"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}