<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>LINICKX.com</title><link>https://www.linickx.com/</link><description></description><lastBuildDate>Fri, 13 Mar 2015 08:00:00 +0000</lastBuildDate><item><title>bash: ls modified or added files</title><link>https://www.linickx.com/bash-ls-modified-or-added-files</link><description>&lt;p&gt;One of the most useful features of OSX's finder is bing able to sort files by modified or added. In my typical workflow I use a &lt;code&gt;$SHELL&lt;/code&gt; to move around directories and then use &lt;code&gt;open .&lt;/code&gt; to open finder in the right location.&lt;/p&gt;
&lt;p&gt;To speed things up a little more, I've knocked up a couple of alias's for my &lt;code&gt;.bash_profile&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;lm&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Works on both linux and OSX&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    listmodifiedfiles() {

        lmdir=&amp;quot;.&amp;quot;
        lmdir=${1:-$lmdir}

        if [ -z &amp;quot;$2&amp;quot; ]
        then
            lmnum=&amp;quot;-5&amp;quot;
        else
            lmnum=$(($2 * -1))
        fi

        ls -1t $lmdir | head $lmnum
    }
    alias lm=listmodifiedfiles
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This adds an &lt;code&gt;lm&lt;/code&gt; alias/command that will list the last 5 modified files. The command takes two options the first being a directory, the second being the number of files to list.&lt;/p&gt;
&lt;p&gt;E.g.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    linickx:dotcom nick$ lm ./content/posts/ 3
    bash-ls-modified-or-added-files.md
    css-styling-nginx-directory-listings.md
    good-bye-wordpress-hello-pelican.md
    linickx:dotcom nick$
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;la&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Works on OSX only&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    listaddedfiles() {

        ladir=&amp;quot;.&amp;quot;
        ladir=${1:-$ladir}

        if [ -z &amp;quot;$2&amp;quot; ]
        then
            lanum=&amp;quot;-5&amp;quot;
        else
            lanum=$(($2 * -1))
        fi

        ls -lrt -d -1 $ladir/* | grep -v '^\.$\|^\.\.$' | xargs -I {} mdls -name kMDItemFSName -name kMDItemDateAdded {} | sed 'N;s/\n//' | grep -v '(null)' | awk '{gsub(/&amp;quot;/, &amp;quot;&amp;quot;, $7);print $3 &amp;quot; &amp;quot; $4 &amp;quot; &amp;quot; $7}' | sort -r | awk '{print $3}' | head $lanum
    }
    alias la=listaddedfiles
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This add an &lt;code&gt;la&lt;/code&gt; alias/command that will list the last 5 added files. As before, the command takes two options the first being a directory, the second being the number of files to list. e.g.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    linickx:~ nick$ la ~/Downloads/
    GZC4573714.zip
    AdobeFlashPlayerInstaller_17au_ltrosxd_aaa_aih.dmg
    Defaultselfsignedservercerti.pem
    linickx:~ nick$
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; This command takes a long-ish time to run on big directories as each file has to have it's meta data checked prior to output. If anyone a suggestion to make this quicker &lt;a href="https://www.linickx.com/contact"&gt;I'm all ears&lt;/a&gt; !&lt;/p&gt;
&lt;p&gt;References:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;http://stackoverflow.com/questions/15691359/how-can-i-list-ls-the-5-last-modified-files-in-a-directory&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;http://apple.stackexchange.com/questions/86307/can-i-list-files-ordered-by-date-added-to-a-folder-from-a-command-line-tool-like&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nick Bettison</dc:creator><pubDate>Fri, 13 Mar 2015 08:00:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2015-03-13:bash-ls-modified-or-added-files</guid><category>os</category><category>linux</category><category>bash</category></item><item><title>OS X: Converting videos but keeping the timestamp</title><link>https://www.linickx.com/os-x-converting-videos-but-keeping-the-timestamp</link><description>&lt;p&gt;I got a new computer, w00t! My family like to use the point-and-click
camera for adhoc videos whilst we're out and about, the thing is it's
very old and records in a rubbish AVI format which consumes massive
amounts of disk space, b000!&lt;/p&gt;
&lt;p&gt;After a bit of googling I wrote the below, it'll search through your
disk and find AVI files, check that the file extension is .AVI and then
convert it to .mp4; for bonus points it'll change the timestamp of the
mp4 to match the avi so that it'll import into iPhoto albums nicely.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin.bash
export IFS=$'\n'
for i in $(find ./ -type f -name '*.AVI') 
    do 
        if [ ${i: -4} == ".AVI" ]
            then
            echo "Converting $i"
            ffmpeg -i "$i" -s 480x320 -aspect 4:3 -b 768k -ab 64k -ar 22050 -r 30000/1001 "${i%.AVI}.mp4"
            sleep 5
            TSTAMP=`gls -l --time-style=+%Y%m%d%H%m "$i" | awk '{print $6}'`
            touch -mt $TSTAMP "${i%.AVI}.mp4"
            sleep 5 
            rm -f "$i"
        fi
    done
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Quick Note: &lt;code&gt;gls&lt;/code&gt; is the GNU version of &lt;code&gt;ls&lt;/code&gt; not the built in BSD-MAC
version, you get it via &lt;a href="http://mxcl.github.com/homebrew/"&gt;homebrew&lt;/a&gt;
(&lt;code&gt;brew install coreutils&lt;/code&gt;)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Wed, 06 Mar 2013 18:24:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2013-03-06:os-x-converting-videos-but-keeping-the-timestamp</guid><category>bash</category><category>mac</category><category>osx</category><category>script</category></item><item><title>Building a free Dynamic DNS client with rackspace Cloud</title><link>https://www.linickx.com/building-a-free-dynamic-dns-client-with-rackspace-cloud</link><description>&lt;p&gt;&lt;a href="http://www.rackspace.com/cloud/cloud_hosting_products/dns/"&gt;&lt;img alt="rsdns" src="https://www.linickx.com/files/2011/10/rsdns.png" title="rsdns" /&gt;&lt;/a&gt;&lt;br /&gt;
As a &lt;a href="http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-servers/"&gt;cloud
server&lt;/a&gt;
customer you get access to &lt;a href="http://www.rackspace.com/cloud/cloud_hosting_products/dns/"&gt;rackspace's free DNS
service&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When I fist saw this product I had an instance light-bulb moment, I
could stop paying for a dynamic DNS service and build my own private
one. As a broadband (DHCP) user I have a very basic requirement of
needing to regularly update an A record so that I can find my pc :)&lt;/p&gt;
&lt;p&gt;To bring my idea into fruition I began researching; I need a cli tool
which I could run from cron on my linux box (&lt;em&gt;to send the DNS update
requests to rackspace&lt;/em&gt;). In my research I found
&lt;a href="https://github.com/jsquared"&gt;rscurl&lt;/a&gt;, a cli tool to control cloud
servers, as rackspace have a standard API for all their products I have
been able to use rscurl to develop
&lt;a href="https://github.com/linickx/rsdns"&gt;rsdns.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;rsdns is a series of cli tools to adding/deleting/changing rackspace DNS
records, as part of the tool development I have created a script called
&lt;code&gt;rsdns-dc.sh&lt;/code&gt; to run on my machine, below is a short how to:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to get free dynamic dns from rackspace.&lt;/strong&gt;&lt;/p&gt;
&lt;!--more--&gt;

&lt;p&gt;&lt;u&gt;Pre-requisit&lt;/u&gt;: This is for linux/mac, if you want to do this on
windows you'll need bash, curl, awk, sed &amp;amp; dig installed - google is
your friend.&lt;/p&gt;
&lt;p&gt;The instructions below assume that you (a) have a domain and (b) have
already changed your NS records to point to dns1.stabletransit.com &amp;amp;
dns2.stabletransit.com.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/linickx/rsdns/tarball/master"&gt;Download the latest rsdns from
gitgub&lt;/a&gt; and unpack
somewhere, I like &lt;code&gt;~/bin/rsdns&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Go to your rackspace management portal and grap your username &amp;amp; API key
(&lt;em&gt;It's under "Your Account" -&amp;gt; "API Access"&lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;Create a config file for rsdns (&lt;code&gt;~/.rsdns_config&lt;/code&gt;) with your settings.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
RSUSER=linickx  
RSAPIKEY=123456  
RSPATH=~/bin/rsdns/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You need your domain &lt;em&gt;created&lt;/em&gt; on rackspace, you can either use
rackspaces GUI to do this (&lt;em&gt;It's under "Hosting" -&amp;gt; "Cloud Servers" -&amp;gt;
"serverabc" -&amp;gt; "DNS"&lt;/em&gt; ) or you can use rsdns, like so.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
[LINICKX@SERVER rsdns]$./rsdns-domain.sh -d www.linickx.com -e spam@linickx.com
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once you have a domain setup you need an A record, this step was a
deliberate design to avoid any rouge cron jobs from creating a million
records, the dynamic client will only update an existing record - not
create a new one.&lt;/p&gt;
&lt;p&gt;To create the a record you going to need an IP address, it can be
something random like the below, or you can use &lt;a href="http://icanhazip.com"&gt;http://icanhazip.com&lt;/a&gt;
to get your actual current IP. Again to create a record, you can use the
rackspace GUI (&lt;em&gt;It's under "Hosting" -&amp;gt; "Cloud Servers" -&amp;gt;
"serverabc" -&amp;gt; "DNS" -&amp;gt; "yourdomain" &amp;gt; "Add"&lt;/em&gt;) or you can use
rsdns....&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
[LINICKX@SERVER rsdns]$./rsdns-a.sh -n dynamichost.linickx.com -i 123.123.123.123 -t 3600
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the above the TTL is set to 1hr, this is so that DNS caches do not
keep the record too long. That's all the pre-work done, now lets get
your dynamic host setup!&lt;/p&gt;
&lt;p&gt;The script to update your a record is &lt;code&gt;rsdns-dc.sh&lt;/code&gt;, and you run it like
this...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
[LINICKX@SERVER rsdns]$./rsdns-dc.sh -n dynamichost.linickx.com
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Easy huh? The script uses icanhazip to get your current IP, it then
update the A record with it.&lt;/p&gt;
&lt;p&gt;I never switch off my router so I have create a created a cronjob to run
that script every 2 hours, plus the 1hr TTL &lt;em&gt;should&lt;/em&gt; mean that the
record is roughly in sync with my IP without making unnecessary
requests - You can run the script more often if you like, just stay
under the limits --&amp;gt; according to &lt;a href="http://docs.rackspace.com/cdns/api/v1.0/cdns-devguide/content/Rate_Limits-d1e1222.html"&gt;the API
guidelines&lt;/a&gt;
you can make upto 25 changes per min / 2 per second.&lt;/p&gt;
&lt;p&gt;I use redhat based linux systems, so I can simply drop the following
file called rsdns-dc into &lt;code&gt;/etc/cron.d/&lt;/code&gt; with this...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;* */2  * * *     linickx /home/linickx/bin/rsdns/rsdns-dc.sh -n dynamichost.linickx.com &amp;amp;&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we are actually done! Free private Dynamic DNS on your own zone,
what more could you want?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Sun, 30 Oct 2011 21:46:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2011-10-30:building-a-free-dynamic-dns-client-with-rackspace-cloud</guid><category>bash</category><category>github</category><category>how to</category><category>Linux</category><category>rsdns</category></item><item><title>Cisco ASA Firewalls and IP Ranges in ACLS</title><link>https://www.linickx.com/cisco-asa-firewalls-and-ip-ranges-in-acls</link><description>&lt;p&gt;I've google'd and I cannot find a way of creating a firewall range style
object in an ASA, you know the kind of thing whereby you want to allow
IP addresses 192.168.1.10 thru 192.168.1.20 in an ACL.&lt;/p&gt;
&lt;p&gt;In my frustration I have given up and created a shell script which
converts a CSV into an ASA output, simply create a two column CSV with
Col A containing your starting IP and Col B containing you end IP.&lt;/p&gt;
&lt;p&gt;The script is a recursive loop so should support large outputs such as
10.1.2.10 to 10.2.1.20 howvere I'm not actually sure you'd want that in
your firewall config but I wrote the computability for the fun it!&lt;/p&gt;
&lt;p&gt;Have fun, click "more" below if you can't see the script!&lt;/p&gt;
&lt;!--more--&gt;

&lt;pre&gt;&lt;code&gt;#!/bin.bash

# Commas separated VAR....
IFS=","
while read name firstip lastip
# Loop around CSV
do

# Split up our first ip into it's octects
firstipfirstoctect=$(echo $firstip | awk -F "." '{print $1}')
firstipsecondoctect=$(echo $firstip | awk -F "." '{print $2}')
firstipthirdoctect=$(echo $firstip | awk -F "." '{print $3}')
firstipforthoctect=$(echo $firstip | awk -F "." '{print $4}')

# Split up our last IP into it's ocects
lastipfirstoctect=$(echo $lastip | awk -F "." '{print $1}')
lastipsecondoctect=$(echo $lastip | awk -F "." '{print $2}')
lastipthirdoctect=$(echo $lastip | awk -F "." '{print $3}')
lastipforthoctect=$(echo $lastip | awk -F "." '{print $4}')

    # Re-set BASH
    unset IFS

    # Echo out the object GROUP name
    echo "object-group network $name"

    # Loop through 1st Octect
    for a in `seq $firstipfirstoctect $lastipfirstoctect`;
    do
        # test to see if we need to print the whole range
        if [ $firstipfirstoctect -lt $lastipfirstoctect ]
        then
            firstipsecondoctectCOUNTER="0"
            lastipsecondoctectCOUNTER="255"
        fi

        # first IP might not be 1
        if [ $a -eq $firstipfirstoctect ]
        then
            firstipsecondoctectCOUNTER=$firstipsecondoctect
        fi

        # last IP might not be 255
        if [ $a -eq $lastipfirstoctect ]
        then
            lastipsecondoctectCOUNTER=$lastipsecondoctect
        fi

            # Loop through 2nd Octect
            for b in `seq $firstipsecondoctect $lastipsecondoctect`;
            do

                # Same tests as before except, next octect.
                if [ $firstipsecondoctect -lt $lastipsecondoctect ]
                then
                    firstipthirdoctectCOUNTER="0"
                    lastipthirdoctectCOUNTER="255"
                fi

                if [ $b -eq $firstipsecondoctect ]
                then
                    firstipthirdoctectCOUNTER=$firstipthirdoctect
                fi

                if [ $b -eq $lastipsecondoctect ]
                then
                    lastipthirdoctectCOUNTER=$lastipthirdoctect
                fi

                    # Loop through 3rd Octect
                    for c in `seq $firstipthirdoctectCOUNTER $lastipthirdoctectCOUNTER`;
                    do

                        # copy / paste / tweak
                        if [ $firstipthirdoctect -lt $lastipthirdoctect ]
                        then
                            firstipforthoctectCOUNTER="0"
                            lastipforthoctectCOUNTER="255"
                        fi

                        if [ $c -eq $firstipthirdoctect ]
                        then
                            firstipforthoctectCOUNTER=$firstipforthoctect
                        fi

                        if [ $c -eq $lastipthirdoctect ]
                        then
                            lastipforthoctectCOUNTER=$lastipforthoctect
                        fi

                            # final octect... echo result.
                            for d in `seq $firstipforthoctectCOUNTER $lastipforthoctectCOUNTER`;
                            do
                                echo " network-object $a.$b.$c.$d  255.255.255.255"
                            done

                    done
            done
    done

done&amp;lt;./FirewallRanges.csv
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Fri, 29 Jul 2011 15:05:00 +0100</pubDate><guid isPermaLink="false">tag:www.linickx.com,2011-07-29:cisco-asa-firewalls-and-ip-ranges-in-acls</guid><category>asa</category><category>bash</category><category>Cisco</category><category>firewall</category><category>script</category><category>Security</category></item><item><title>GTD in your Shell</title><link>https://www.linickx.com/gtd-in-your-shell</link><description>&lt;p&gt;For the last few months I've felt better at managing my actions and
tasks thanks to &lt;a href="http://stevelosh.com/projects/t/"&gt;Steve Losh's T&lt;/a&gt;. T is
a simple python script that allows you to manage a simple task list from
your shell prompt.&lt;/p&gt;
&lt;p&gt;I use my shell all the time to ping stuff, renice processes and you
know, whatever (&lt;em&gt;like in the image below&lt;/em&gt;).....&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.linickx.com/files/2011/04/GTD_iTerm.png"&gt;&lt;img alt="Screenshot of T in
iTerm" src="https://www.linickx.com/files/2011/04/GTD_iTerm-300x146.png" title="Getting Things Done in my Terminal" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;... having my todo list right there in front of me has been really
helpful (&lt;em&gt;The numbers in the square brackets!&lt;/em&gt;). Steve's website
suggests a quick update to your shell profile to add your task list to
your prompt but I found running a python script each time I do anything
quite slow, especially since I have two lists.&lt;/p&gt;
&lt;p&gt;Below is my bash .profile file, there you can see the rather
&lt;abbr title="yes, I mean over the top!"&gt;OTT&lt;/abbr&gt; change(s) I've made
to integrate my todo lists into my shell prompt. I have two lists (&lt;em&gt;work
&amp;amp; personal&lt;/em&gt;) the number of things to do shown in my shell prompt gets
updated each time the lists change (&lt;em&gt;thanks to md5&lt;/em&gt;).... and I hide my
work list over the weekend ;)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
alias p='python ~/bin/t/t.py --task-dir ~/Dropbox/Tasks --list personal.tasks --delete-if-empty'
alias w='python ~/bin/t/t.py --task-dir ~/Dropbox/Tasks --list work.tasks --delete-if-empty'

function nick_PS1 {

        if [ -e "/Users/nick/Dropbox/Tasks/Personal.tasks" ]
        then
                CurrentPersonalMD5=`md5 ~/Dropbox/Tasks/Personal.tasks | awk '{print $4}' | cat `

                if [ -e "~/.tasks.personal.md5" ]
                then
                        LastPersonalMD5=`cat ~/.tasks.personal.md5`
                fi

                if [ "$CurrentPersonalMD5" == "$LastPersonalMD5" ]
                then
                        if [ -e "~/.tasks.personal.no" ]
                        then
                                NumOfPersonal=`cat ~/.tasks.personal.no`
                        fi
                else
                        NumOfPersonal=`p | wc -l | sed -e's/ *//'`
                        echo $NumOfPersonal &amp;gt; ~/.tasks.personal.no
                        echo $CurrentPersonalMD5 &amp;gt; ~/.tasks.personal.md5
                fi

                if [ $NumOfPersonal -ne 0 ]
                then
                        LEFT='['
                        RIGHT=']'
                        Personal="p:$NumOfPersonal"
                fi

        else
                NumOfPersonal=0
        fi

DayOfWeek=`date "+%u"`
if [ $DayOfWeek -lt 6 ]
then
        if [ -e "/Users/nick/Dropbox/Tasks/Work.tasks" ]
        then
                CurrentWorkMD5=`md5 ~/Dropbox/Tasks/Work.tasks | awk '{print $4}'`

                if [ -e "~/.tasks.work.md5" ]
        then
                LastWorkMD5=`cat ~/.tasks.work.md5`
        fi

                if [ "$CurrentWorkMD5" == "$LastWorkMD5" ]
        then
                        if [ -e "~/.tasks.work.no" ]
                        then
                                NumOfWork=`cat ~/.tasks.work.no`
                        fi
                else
                                        NumOfWork=`w | wc -l | sed -e's/ *//'`
                                        echo $NumOfWork &amp;gt; ~/.tasks.work.no
                                        echo $CurrentWorkMD5 &amp;gt; ~/.tasks.work.md5
                fi

                if [ $NumOfWork -ne 0 ]
                then
                        LEFT='['
                        RIGHT=']'
                        Work="w:$NumOfWork"
                fi

        else
                NumOfWork=0
        fi
else
 NumOfWork=0
fi

        if [ $NumOfPersonal -ne 0 ]
        then
                if [ $NumOfWork -ne 0 ]
                then
                        SEP="|"
                fi
         fi

        RESULT="$LEFT$Personal$SEP$Work$RIGHT"

        if [ -z $RESULT ] 
        then
                RESULT="linickx@macbookpro"
        fi

        echo $RESULT
}

export PS1="\$(nick_PS1) \W \$"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;... I think my next stop will be using geektool show the list/reminders
on my desktop.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Tue, 26 Apr 2011 21:27:00 +0100</pubDate><guid isPermaLink="false">tag:www.linickx.com,2011-04-26:gtd-in-your-shell</guid><category>bash</category><category>Blog</category><category>GTD</category><category>shell</category><category>t</category></item><item><title>Lowing VirtualBox priorities</title><link>https://www.linickx.com/lowing-virtualbox-priorities</link><description>&lt;p&gt;One of the things &lt;a href="http://forums.virtualbox.org/viewtopic.php?f=9&amp;amp;t=34341"&gt;I'd really
like&lt;/a&gt; is process
priorities for virtual box. In the forum I posted a couple of shell
commands that I regularly type... which gets a bit tedious, following a
recent article on lifehacker &lt;a href="http://lifehacker.com/#!5749631/the-mac-text-expansion-face-off"&gt;reviewing mac text
expanding&lt;/a&gt;
I've been prompted to automate a few things... below is a little shell
script to lower the priority (&lt;em&gt;renice&lt;/em&gt;) of all running virtual machines.&lt;/p&gt;
&lt;p&gt;The advantage of doing this is that your host machine stays snappy,
responsive and won't get too over-loaded by jobs on your VMs!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin.bash
ps -xo pid,command | grep -v grep | grep startvm | while read line ;
do
        procID=`echo $line | awk '{print $1}'`
        sudo renice +10 -p $procID
done
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above code works on a mac; although I haven't tested it, I recon to
get it running on Linux you need to update the PS command, by swapping
the x for an e... like this....&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin.bash
ps -eo pid,command | grep -v grep | grep startvm | while read line ;
do
        procID=`echo $line | awk '{print $1}'`
        sudo renice +10 -p $procID
done
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Have fun, suggestions and improvements welcome.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Mon, 14 Feb 2011 17:30:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2011-02-14:lowing-virtualbox-priorities</guid><category>automation</category><category>bash</category><category>Blog</category><category>Linux</category><category>mac</category><category>virtualbox</category></item><item><title>Bash script to fix file permissions recursively</title><link>https://www.linickx.com/bash-script-to-fix-file-permissions-recursively</link><description>&lt;p&gt;I love the redhat implementation of cron, simply drop a shell script
into &lt;code&gt;/etc/cron.daily/&lt;/code&gt; and your script will be executed every day (&lt;em&gt;by
default at 4am&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Recently I've been having a small
&lt;a href="https://sourceforge.net/forum/forum.php?thread_id=1961180&amp;amp;forum_id=440751"&gt;problem&lt;/a&gt;
with &lt;a href="http://mediatomb.cc/"&gt;mediatomb&lt;/a&gt;, further investigation lead me to
&lt;a href="https://sourceforge.net/forum/message.php?msg_id=4828164"&gt;a "Inotify thread caught exception"
error&lt;/a&gt; which
can be fixed by recursively resetting your file permissions.&lt;/p&gt;
&lt;p&gt;What I have done to fix the issue is save the following code as
&lt;code&gt;/etc/cron.daily/fix_mt.sh&lt;/code&gt; and 'jobs a gooden' :cool:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
# Load up your mediatomb directories...
MediaTombDirectories[0]="/home/me/Videos"
MediaTombDirectories[1]="/home/me/Music"
# add more if needbe
# MediaTombDirectories[2]="/home/me/files"

# Setup find correctly.
export IFS=$'\n'

# Loop through our array.
for x in ${MediaTombDirectories[@]}
    do 
        # Find all directories &amp;amp; subdirectories
        for i in $(find $x -type d) 
            do 
                # Fix Permissions
                chmod -c 775 $i
                chown -c me:user $i
            done

        # Find all Files
        for i in $(find $x -type f) 
            do 
                # Fix Permissions
                chmod -c 664 $i
                chown -c me:user $i
            done
    done
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;br /&gt;
Quick tip:&lt;/strong&gt; You (&lt;em&gt;or root&lt;/em&gt;) will get e-mailed every time this
executes, you can make the script more verbos by changing all "&lt;code&gt;-c&lt;/code&gt;" to
"&lt;code&gt;-v&lt;/code&gt;", or make it silent by removing the "&lt;code&gt;-c&lt;/code&gt;" altogether.&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Thu, 26 Jun 2008 19:00:00 +0100</pubDate><guid isPermaLink="false">tag:www.linickx.com,2008-06-26:bash-script-to-fix-file-permissions-recursively</guid><category>bash</category><category>cron</category><category>Linux</category><category>mediatomb</category></item><item><title>History Meme - What's your shell top 10?</title><link>https://www.linickx.com/history-meme-whats-your-shell-top-10</link><description>&lt;p&gt;&lt;a href="http://www.google.com/custom?hl=en&amp;amp;client=google-coop&amp;amp;cof=AH%3Aleft%3BS%3Ahttp%3A%2F%2Fplanet.gnome.org%2F%3BCX%3ABloggers%2520of%2520Planet%2520GNOME%3BL%3Ahttp%3A%2F%2Fwww.gnome.org%2Fimg%2Flogo%2Ftext-64%3BLH%3A64%3BLP%3A1%3BGFNT%3A%23666666%3BDIV%3A%23cccccc%3B&amp;amp;adkw=AELymgVuQoYfvsheM6KA6z8eBquUjnbxaM51ouim04L3q497yAuT4d5y7BOqpREvwI7hHZLLATbHsG16s_IindkbId-BmIBZDBTPTxGSBe-1lcUh4VPn8o0JuwbPpxnaNMefCT5vj5Tt&amp;amp;q=awk+print+sort+head&amp;amp;btnG=Search&amp;amp;cx=007525575524326405779%3Ac0gv0y410u0"&gt;Planet gnome have started a
trend&lt;/a&gt;...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
114 ping
107 sudo
82 ssh
71 top
71 cd
68 iwconfig
56 ls
46 usbkey.sh
43 ps
33 evolution
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output shows what commands you type the most, &lt;code&gt;usbkey.sh&lt;/code&gt; is a
script to unlock the secret-keys held on my usb key-fob, sudo is high up
probably cause I use sudo to bounce services (&lt;em&gt;the intel wireless drive
crashes quite alot and both it and Network Manager then need
restarting&lt;/em&gt;) and evolution needs a shutdown every now and again :( The
other commands are fairly self-explanatory.&lt;/p&gt;
&lt;p&gt;So what's your history?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Fri, 18 Apr 2008 09:51:00 +0100</pubDate><guid isPermaLink="false">tag:www.linickx.com,2008-04-18:history-meme-whats-your-shell-top-10</guid><category>bash</category><category>history meme</category><category>Linux</category></item><item><title>Bash looping through directories &amp; sub-directoires</title><link>https://www.linickx.com/bash-looping-through-directories-sub-directoires</link><description>&lt;p&gt;Note to self.... If I want to "do" something to all files in all
sub-directories then I need.....&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#!/bin/bash export IFS=$'\n' for i in $(find $1 -type f)     do         echo "$i"     done&lt;/code&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Tue, 05 Feb 2008 11:18:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2008-02-05:bash-looping-through-directories-sub-directoires</guid><category>bash</category><category>Linux</category><category>programming</category></item></channel></rss>