Top-rated Bash recipes http://code.activestate.com/recipes/langs/bash/top/2017-05-13T12:12:30-07:00ActiveState Code RecipesDirectories tree (Bash)
2013-10-11T07:11:24-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578684-directories-tree/
<p style="color: grey">
Bash
recipe 578684
by <a href="/recipes/users/4184115/">greg zakharov</a>
(<a href="/recipes/tags/tree/">tree</a>).
</p>
<p>Imitation of tree -d command.</p>
Open a python module given it's name in Emacs (Bash)
2010-07-19T10:25:06-07:00Noufal Ibrahimhttp://code.activestate.com/recipes/users/4173873/http://code.activestate.com/recipes/577317-open-a-python-module-given-its-name-in-emacs/
<p style="color: grey">
Bash
recipe 577317
by <a href="/recipes/users/4173873/">Noufal Ibrahim</a>
(<a href="/recipes/tags/emacs/">emacs</a>, <a href="/recipes/tags/modules/">modules</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python_developer_tools/">python_developer_tools</a>, <a href="/recipes/tags/zsh/">zsh</a>).
</p>
<p>A tiny little <code>zsh</code> function to open a python module in <code>Emacs</code>. Assumes that an <code>Emacs</code> server process is running. </p>
A white noise generator to sooth baby to sleep. (Bash)
2017-05-13T12:12:30-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/580801-a-white-noise-generator-to-sooth-baby-to-sleep/
<p style="color: grey">
Bash
recipe 580801
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/alarm/">alarm</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/baby_alarm/">baby_alarm</a>, <a href="/recipes/tags/cygwin/">cygwin</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/noise/">noise</a>, <a href="/recipes/tags/sleep/">sleep</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/whitenoise/">whitenoise</a>).
</p>
<p>This is a simple BASH, DASH and SH script to sooth a newborn baby to sleep for a laptop with a builtin mic. Develeoped around an Apple MacBook Pro.</p>
<p>Usage:- [./]shush.sh <time in seconds from 18 to 2700> [sensitivity [Hh|Mm|Ll]]<CR></p>
<p>If time is omitted it defaults to 2 bursts of 9 seconds each and if sensitivity is omitted defaults to [M]edium.</p>
<p>It uses Quicktime Player for Apple OSX 10.12.4 minimum /dev/dsp for CygWin and some Linux flavours and arecored for Linux ALSA machines for baby awake detector.</p>
<p>Upon the two arguments the white noise generator runs for approximately the time given in $1 in bursts of 9 seconds until the time limit is reached.
$2 is used to detect of baby is awake and reruns the noise generator again with a new noise waveform.</p>
<p>Enjoy...</p>
A simple Unix shell utility to save cleaned-up man pages as text (Bash)
2017-03-25T14:12:25-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580766-a-simple-unix-shell-utility-to-save-cleaned-up-man/
<p style="color: grey">
Bash
recipe 580766
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/documentation/">documentation</a>, <a href="/recipes/tags/man/">man</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/utilities/">utilities</a>, <a href="/recipes/tags/utility/">utility</a>).
</p>
<p>It's a shell script that lets you save the man pages for one or more Unix commands, system calls or other topics, to text files, after cleaning up the man command output to remove formatting meant for emphasis, printing, etc.</p>
<p>More information here:</p>
<p><a href="https://jugad2.blogspot.in/2017/03/m-unix-shell-utility-to-save-cleaned-up.html" rel="nofollow">https://jugad2.blogspot.in/2017/03/m-unix-shell-utility-to-save-cleaned-up.html</a></p>
A simple shell script to keep the wife off of your back... (Bash)
2013-12-09T20:05:49-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578781-a-simple-shell-script-to-keep-the-wife-off-of-your/
<p style="color: grey">
Bash
recipe 578781
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/reminder/">reminder</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/shell/">shell</a>).
</p>
<p>How many times have you been asked to remember to do something from the other half whilst she is out for a short while.</p>
<p>For example: "You WILL check the dinner every few minutes won't you?"</p>
<p>And how many times did/do you forget?</p>
<p>Most of us have been there...</p>
<p>This is a simple kids level, practical learning, shell script that generates an "xterm" with your reminder inside every 30 seconds for a period of 3 seconds.</p>
<p>It is always be the active front window for 3 seconds at a time to _annoy_ you into remembering.</p>
<p>Usage: reminder "What you have to remember here using spaces AND double quotes."<CR></p>
<p>Just reanme the downloaded script to reminder and remember to chmod it as required.</p>
<p>Just run it from your default terminal and when finished press Ctrl-C just AFTER the xterm window closes.</p>
<p>There is NO error detection so steer clear of any special characters in you reminder text.</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
scan db to login the ssh servers (Bash)
2010-03-16T13:11:17-07:00J Yhttp://code.activestate.com/recipes/users/4170398/http://code.activestate.com/recipes/576877-scan-db-to-login-the-ssh-servers/
<p style="color: grey">
Bash
recipe 576877
by <a href="/recipes/users/4170398/">J Y</a>
(<a href="/recipes/tags/awk/">awk</a>, <a href="/recipes/tags/bash/">bash</a>).
Revision 2.
</p>
<p>awk with parameters passed from bash</p>
A script to automate installing MTS Mblaze UI in linux (Bash)
2015-07-29T18:26:59-07:00Emil george jameshttp://code.activestate.com/recipes/users/4191910/http://code.activestate.com/recipes/579039-a-script-to-automate-installing-mts-mblaze-ui-in-l/
<p style="color: grey">
Bash
recipe 579039
by <a href="/recipes/users/4191910/">Emil george james</a>
(<a href="/recipes/tags/internet/">internet</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/web/">web</a>).
</p>
<p>An automate shell linux script to install mts mblaze ui application in all linux distros.this shell script automatically install the mts mblaze ui in your linux systems .installation script will setup everything need to choose some option interactively from setup.Script can work for all linux environments.</p>
Obfuscation In Bash Shell. (Bash)
2014-12-19T20:01:30-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578986-obfuscation-in-bash-shell/
<p style="color: grey">
Bash
recipe 578986
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/obfuscation/">obfuscation</a>).
</p>
<p>IMO, the immense power of the shell...</p>
<p>Please let me know if there is any other human readable language that can do this...</p>
<p>The DEMO code below was an idea I formed to see how to make a bash script very difficult to hack.</p>
<p>Everything in it is made easy to read so as to see this idea working.</p>
<p>It uses bash variables ONLY and although I have used bash loops to create the variables in this
DEMO you could create your own set of variables and 'source' them to the the obfuscated code before
running the main body of the code.</p>
<p>It also goes without saying that you could obfuscate the changing of any or all the variable
allocations at any time AFTER the code runs to make it even more obfuscated and as may times as
you wish...</p>
<p>I would be seriously difficult to actually write a lsrge bash app' using this method but boy oh boy
would it be fun?!?</p>
<p>Testbed:- Macbook Pro, OSX 10.7.x and above, using default bash terminal...</p>
<p>LBNL, yeah I am aware of 'eval' but as it is obfuscated and can have as many obfuscated variables as
I wish allocated to it then why worry... ;o)</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza...</p>
Get external IP & geolocation in bash. (Bash)
2014-11-30T00:46:28-08:00manuhttp://code.activestate.com/recipes/users/4191225/http://code.activestate.com/recipes/578972-get-external-ip-geolocation-in-bash/
<p style="color: grey">
Bash
recipe 578972
by <a href="/recipes/users/4191225/">manu</a>
(<a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/geocoding/">geocoding</a>, <a href="/recipes/tags/geolocation/">geolocation</a>).
Revision 2.
</p>
<p>Very simple way to get external IP and geolocation uysing dig and geoiplookup.</p>
<p><code>dig</code> is cool to obtain my external IP and I use <code>geoiplookup</code> to convert IP to location. You need geoip-bin and, geoip-database (and/or geoip-database-contrib and geoip-database-extra). In Debian, database seems update monthly.</p>
<p>It's just a tip.</p>
Print selected text pages to PDF with Python, selpg and xtopdf on Linux (Bash)
2014-10-29T17:38:10-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578954-print-selected-text-pages-to-pdf-with-python-selpg/
<p style="color: grey">
Bash
recipe 578954
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/reportlab/">reportlab</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/text_files/">text_files</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/unix/">unix</a>).
</p>
<p>This recipe shows how to use selpg, a Linux command-line utility written in C, together with xtopdf, a Python toolkit for PDF creation, to print only a selected range of pages from a text file, to a PDF file, for display or print purposes. The way to do this is to run the selpg utility at the Linux command line, with options specifying the start and end pages of the range, and pipe its output to the StdinToPDF.py program, which is a part of the xtopdf toolkit.</p>
A Fun Perfect Square Checker Using Integer Arithmetic Only... ;o) (Bash)
2014-09-16T22:27:04-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578934-a-fun-perfect-square-checker-using-integer-arithme/
<p style="color: grey">
Bash
recipe 578934
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/arithmetic/">arithmetic</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/check/">check</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/cygwin/">cygwin</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/perfect/">perfect</a>, <a href="/recipes/tags/root/">root</a>, <a href="/recipes/tags/square/">square</a>).
</p>
<p>A recent Python upload here gave me the inspiration to do a bash version...
This is a little tongue-in-cheek but an enjoyable bit of fun.</p>
<p>It took around 11 seconds to prove 90000000000 had a perfect square of 300000...</p>
<p>It is a stand alone program and has a degree of INPUT error correction...</p>
<p>It was done on a MacBook Pro, OSX 10.7.5, default bash terminal and should work on Linux flavours but it is untested...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza...</p>
Simple Bash Text Mode Sine Curve Generator. (Bash)
2014-08-12T20:57:39-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578921-simple-bash-text-mode-sine-curve-generator/
<p style="color: grey">
Bash
recipe 578921
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/cygwin/">cygwin</a>, <a href="/recipes/tags/graph/">graph</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/text/">text</a>).
Revision 2.
</p>
<p>This bash script is a taster for a kids level, audio, text mode, sweep generator.
The code just creates a single cycle of a quantised sine curve inside an 80 x 24 bash terminal.
This will be the calculator for a sinewave sweep generator from about 50Hz the 12KHz...
The code tells you more and the display is in comments at the end...</p>
A Bash Beep Command For OSX 10.7+... (Bash)
2014-02-27T19:36:17-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578837-a-bash-beep-command-for-osx-107/
<p style="color: grey">
Bash
recipe 578837
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/beep/">beep</a>, <a href="/recipes/tags/error_beep/">error_beep</a>, <a href="/recipes/tags/error_sound/">error_sound</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/sound/">sound</a>).
</p>
<p>This small bash script generates an 8044 byte 1KHz sinewave wave file and immediately plays it.
The file created is a _pure_ sinewave and lasts for 1 second. It uses the default "afplay"
command to run the generated file.</p>
<p>It was designed around an Apple Macbook Pro but using "aplay" it might even work on other *nix
flavours from the command line. I have not bothered to try it as this was purely for my MB Pro.</p>
<p>The wave file can be found as "/tmp/sinewave.wav" during the working session(s) and can be saved
anywhere of your choice.</p>
<p>Enjoy...</p>
<p>(Watch for word wrapping etc...)</p>
<p>Bazza.</p>
Zenity Chunk Editor, creating an hashing to preserve Code Integrity. (Bash)
2013-10-22T01:30:42-07:00Patrick Riendeauhttp://code.activestate.com/recipes/users/4175653/http://code.activestate.com/recipes/578693-zenity-chunk-editor-creating-an-hashing-to-preserv/
<p style="color: grey">
Bash
recipe 578693
by <a href="/recipes/users/4175653/">Patrick Riendeau</a>
(<a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/debian/">debian</a>, <a href="/recipes/tags/development/">development</a>, <a href="/recipes/tags/library/">library</a>, <a href="/recipes/tags/mint/">mint</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/ubuntu/">ubuntu</a>).
</p>
<p>It Open by default a uuid-like temporary file. There is no actual was to modify the name, but assuming the implementation of ZenityShellEval imply a limited acces to shell, you might recuperate information from shell or futur adding to transfer a name or simple renaming the uuid-like file-name... This is to prevent auto-execution of a script from canned-design by playing with without having all clearly create your shell script and/or having fully pseudo-code explained and having confirmation of your design work...</p>
<p>Initially, the shell Editor look like this : is: <img src="https://github.com/priendeau/Fnct.d#ZenityShellEval" alt="Image of Zenity Shell In action" /></p>
<p>The dependency are simple, it require My GitHub Fnct.D project, available here: <code>[link](https://github.com/priendeau/Fnct.d)</code> to be installed inside /etc/init.d/Fnct.D like this </p>
<p>git clone <a href="https://github.com/priendeau/Fnct.d" rel="nofollow">https://github.com/priendeau/Fnct.d</a> /etc/init.d/Fnct.D</p>
<p>and loading the Lib first:</p>
<p>. /etc/init.d/Fnct.D/fnct_lib </p>
Checking Gmail for new letters (Bash)
2013-10-11T08:11:38-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578685-checking-gmail-for-new-letters/
<p style="color: grey">
Bash
recipe 578685
by <a href="/recipes/users/4184115/">greg zakharov</a>
(<a href="/recipes/tags/gmail/">gmail</a>).
</p>
<p>Note: enter name of your email without "@gmail.com"</p>
find + grep (Bash)
2013-09-17T08:48:07-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/578661-find-grep/
<p style="color: grey">
Bash
recipe 578661
by <a href="/recipes/users/4184815/">yota</a>
(<a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/zsh/">zsh</a>).
Revision 2.
</p>
<p>look for a text pattern in files defined by a pattern.
First argument is passed to the find command, second one to the grep</p>
<p>./find_n_grep.sh '*.py' 'dict'</p>
<p>more over, it sort by date.</p>
Pseudo-3D effect in text mode... (Bash)
2013-09-10T21:23:58-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578655-pseudo-3d-effect-in-text-mode/
<p style="color: grey">
Bash
recipe 578655
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/3d/">3d</a>, <a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/color/">color</a>, <a href="/recipes/tags/colour/">colour</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/text/">text</a>).
</p>
<p>This is just a simple DEMO to display a pseudo-3D effect using a bash script.
It generates a recessed box and a button and writes some thext inside bot.</p>
<p>There are two pieces of code, one for Linux, and one for OSX 10.7.5...</p>
<p>The Linux version also works on OSX 10.7.5 but is harder to see so a near
identical version using the default OSX terminal colours was craeted instead.</p>
<p>You will have to split the two code pieces up yourself to run...</p>
<p>Enjoy finding simple solutions to often very difficult problems...</p>
<p>Bazza...</p>
Bash style commands (Bash)
2013-08-22T13:05:29-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578648-bash-style-commands/
<p style="color: grey">
Bash
recipe 578648
by <a href="/recipes/users/4184115/">greg zakharov</a>
(<a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/cmd/">cmd</a>).
</p>
<p>This is just a concept. To import bash style commands use "script.cmd /bash", to get the list of imported commands use "script.cmd /map"</p>
A Simple Clock, Well Maybe Not That Simple... (Bash)
2013-07-17T17:40:18-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578610-a-simple-clock-well-maybe-not-that-simple/
<p style="color: grey">
Bash
recipe 578610
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/clock/">clock</a>, <a href="/recipes/tags/digital/">digital</a>, <a href="/recipes/tags/digits/">digits</a>, <a href="/recipes/tags/display/">display</a>, <a href="/recipes/tags/large/">large</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/readout/">readout</a>, <a href="/recipes/tags/terminal/">terminal</a>).
</p>
<p>Hi all...</p>
<p>Do you remember this little snippet?</p>
<p><a href="http://code.activestate.com/recipes/578079-pure-fun-for-text-mode-python/?in=user-4177147" rel="nofollow">http://code.activestate.com/recipes/578079-pure-fun-for-text-mode-python/?in=user-4177147</a></p>
<p>Well it was voted down, but who cares? I surely don't!
So to those that voted this FUN piece of Python coding down, you are now about to see what
the aim was.</p>
<p>However although I have subsequently done what I said I would, that is, to create large digits
as an _at_a_glance_ digital readout for a project in Python I have decided not to upload it.
However I have decided to let this one go as a bash/shell script instead.</p>
<p>It is a nothing but a simple clock, well, maybe not that simple; but as I am into shell
stuff at the moment I thought I would share this with you.</p>
<p>The terminal does have its colours changed and the cursor disabled for the session but
I expect you big guns to be able to return back to normal in a jiffy.</p>
<p>I am an amateur coder and if that is easy for me then you pros should have no problems.</p>
<p>This code is not like most of my other stuff as is NOT Public Domain...</p>
<p>It is only a DEMO to see what an at a glance display would look like in a terminal.</p>
<p>Move away to a distance and see which of the two time readings you can still read... ;o)</p>
<p>It is for a Macbook Pro 13" OSX 10.7.5 and uses bash imode.
It will probably work on most Linux machines too but I haven't tested it...</p>
<p>This is purely a DEMO only and any other special effects, (e.g. flashing colon every second),
alram, etc, I have already experimented with and is easy enough to do...</p>
<p>My intention is to use this as a kids level text mode digital voltmeter I am doing.</p>
<p>Enjoy...</p>
<p>Bazza...</p>
A FUN Bash Shell Bomb-Out Error Sound... (Bash)
2013-07-14T19:31:13-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578605-a-fun-bash-shell-bomb-out-error-sound/
<p style="color: grey">
Bash
recipe 578605
by <a href="/recipes/users/4177147/">Barry Walker</a>
(<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/bash/">bash</a>, <a href="/recipes/tags/error_beep/">error_beep</a>, <a href="/recipes/tags/error_sound/">error_sound</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/sound/">sound</a>, <a href="/recipes/tags/sound_exchange/">sound_exchange</a>, <a href="/recipes/tags/sox/">sox</a>).
</p>
<p>Do you remember the Bomb-Out icon(s) that appeared on some computers' SW and HW many years ago...</p>
<p>Well this is a matching sound to go with it and can be used as a critical error sound.</p>
<p>It sounds like a bomb being dropped from an aeroplane and is purely a shell sript only.</p>
<p>It is set up to run SOund eXchange, SOX, but just by editing the code "/dev/dsp" can be used instead.</p>
<p>Read the code for more informastion.</p>
<p>Enjoy...</p>
<p>Bazza...</p>