<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pario TechnoBlob &#187; bash</title>
	<atom:link href="http://pario.no/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://pario.no</link>
	<description>A cronological documentation test project, nothing serious, really!</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:17:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Grab several screenshots from specified window in linux</title>
		<link>http://pario.no/2011/12/02/grab-several-screenshots-from-specified-window-in-linux/</link>
		<comments>http://pario.no/2011/12/02/grab-several-screenshots-from-specified-window-in-linux/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 07:23:01 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[PNG]]></category>
		<category><![CDATA[windowid]]></category>
		<category><![CDATA[wxd]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1651</guid>
		<description><![CDATA[This was a short bash script I wrote to help document some startup problems on a server. The script was grabbing screen dumps from iDRAC during boot on a RHEL6 server, but it can be used on other distributions as well since the console command xwd is common. #!/bin/bash # Description: # Grab screenshot of [...]]]></description>
			<content:encoded><![CDATA[<p>This was a short bash script I wrote to help document some startup problems on a server.<br />
The script was grabbing screen dumps from iDRAC during boot on a RHEL6 server, but it can be used on other distributions as well since the console command xwd is common.</p>
<pre>
#!/bin/bash
# Description:
# Grab screenshot of a specified X-window and wait X-seconds

# Use xwininfo to find the Window id to the window you are going to
# grab screenshots from.
xwininfo="0x4c0001a"

# filename for output
outfile="outfile-"

# seconds sleep between grabs
sleeping=2

padding="000" # put as many padding zeros as you want on filename
for ((i=0; i<1000; i+=1))
do
        # Perform the actual screenshot grab
        xwd -id $xwininfo -out $outfile-${padding:${#i}}$i.xwd

        # Convert the xwd file to a better image format like PNG
        convert $outfile-${padding:${#i}}$i.xwd $outfile-${padding:${#i}}$i.png

        # Delete the converted XWD-file
        rm -f $outfile-${padding:${#i}}$i.xwd

        # wait
        sleep $sleeping
done</pre>
<p>Stop the script after you have grabbed enough screenshots.</p>
<p>I ended up with several files named outfile-000.png outfile-001.png ...<br />
Deleted those files that were not needed and sent the images a documentation of the booting process.</p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTEvMTIvMDIvZ3JhYi1zZXZlcmFsLXNjcmVlbnNob3RzLWZyb20tc3BlY2lmaWVkLXdpbmRvdy1pbi1saW51eC88d3B0Yj5HcmFiIHNldmVyYWwgc2NyZWVuc2hvdHMgZnJvbSBzcGVjaWZpZWQgd2luZG93IGluIGxpbnV4PHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2011/12/02/grab-several-screenshots-from-specified-window-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Randomize filenames</title>
		<link>http://pario.no/2010/09/10/randomize-filenames/</link>
		<comments>http://pario.no/2010/09/10/randomize-filenames/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 21:18:46 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cut]]></category>
		<category><![CDATA[mv]]></category>
		<category><![CDATA[sha1sum]]></category>

		<guid isPermaLink="false">http://pario.no/?p=1402</guid>
		<description><![CDATA[This is a simple bash script to create random filenames of all jpg-files (*.jpg) in a folder using the linux commands mv, sha1sum and cut. #!/bin/bash # Randomize filenames for fname in *.jpg; do mv "$fname" $(echo "$fname" &#124; \ sha1sum &#124; \ cut -f1 -d ' ' &#124; \ cut -b 1-5).jpg done The [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple bash script to create random filenames of all jpg-files (*.jpg) in a folder using the linux commands mv, sha1sum and cut.</p>
<pre>
#!/bin/bash
# Randomize filenames

for fname in *.jpg;
do
        mv "$fname" $(echo "$fname" | \
                sha1sum | \
                cut -f1 -d ' ' | \
                cut -b 1-5).jpg
done
</pre>
<p>The jpg-files can have names like</p>
<pre>
08df4.jpg
1e788.jpg
315e6.jpg
41e19.jpg
5f7d0.jpg
7471e.jpg</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMTAvMDkvMTAvcmFuZG9taXplLWZpbGVuYW1lcy88d3B0Yj5SYW5kb21pemUgZmlsZW5hbWVzPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2010/09/10/randomize-filenames/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy files using tar</title>
		<link>http://pario.no/2009/01/23/copy-files-using-tar/</link>
		<comments>http://pario.no/2009/01/23/copy-files-using-tar/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 15:04:34 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[tar.]]></category>

		<guid isPermaLink="false">http://pario.no/?p=906</guid>
		<description><![CDATA[This is a oneliner to copy files from current directory to another target directory using tar, preserving file attributes, dates etc. #!/bin/sh fromdir=/path/from todir=/path/to/target echo "cd $fromdir; tar cf - . &#124; (cd $todir; tar xpf -)" cd $fromdir; tar cf - . &#124; (cd $todir; tar xpf -)]]></description>
			<content:encoded><![CDATA[<p>This is a oneliner to copy files from current directory to another target directory using tar, preserving file attributes, dates etc.</p>
<pre>
#!/bin/sh

fromdir=/path/from
todir=/path/to/target

echo "cd $fromdir; tar cf - . | (cd $todir; tar xpf -)"

cd $fromdir; tar cf - . | (cd $todir; tar xpf -)
</pre>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDkvMDEvMjMvY29weS1maWxlcy11c2luZy10YXIvPHdwdGI%2BQ29weSBmaWxlcyB1c2luZyB0YXI8d3B0Yj5odHRwOi8vcGFyaW8ubm88d3B0Yj5QYXJpbyBUZWNobm9CbG9i";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2009/01/23/copy-files-using-tar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IP address change notifier script</title>
		<link>http://pario.no/2009/01/21/ip-address-change-notifier-script/</link>
		<comments>http://pario.no/2009/01/21/ip-address-change-notifier-script/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 12:57:16 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Photo etc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ifconfig]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://pario.no/?p=922</guid>
		<description><![CDATA[This is a simple bash script that is run by crontab every 5 minutes on a linux box. It e-mails me the new address when a change of IP address is detected. The script (ipchangemail.sh) #!/bin/bash # Check if IP-address has changed. If a change has occured, mail me the new address # Add the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple bash script that is run by crontab every 5 minutes on a linux box.<br />
It e-mails me the new address when a change of IP address is detected.</p>
<p>The script (ipchangemail.sh)</p>
<pre>
#!/bin/bash 

# Check if IP-address has changed. If a change has occured, mail me the new address
# Add the following line to crontab if you would like it to be run every 5 minutes:
# */5 * * * * ./ipchangemail.sh

# The network interface I want to monitor
NET_INTERFACE=eth0

# File to keep the latest IP address
IP_FILE=myip.txt

# Mail to this address when a change occur
MAILTO=mail@example.com

# Read the previous IP address from file
source $IP_FILE

CURRENT_IP=`/sbin/ifconfig $NET_INTERFACE | sed -n "/inet addr:.*255.255.25[0-5].[0-9]/{s/.*inet addr://; s/ .*//; p}"`

if [ "$CURRENT_IP" != "$OLD_IP" ]
then
        # Send email about address change
        `echo "New IP address detected: $CURRENT_IP" | mail -s "New IP address" $MAILTO`

        # Write new address to file
        `echo "OLD_IP=$CURRENT_IP" > $IP_FILE`
fi
</pre>
<p>The script can be downloaded <a href="http://pario.no/wp-content/uploads/2009/01/ipchangemail.sh">here</a>.</p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDkvMDEvMjEvaXAtYWRkcmVzcy1jaGFuZ2Utbm90aWZpZXItc2NyaXB0Lzx3cHRiPklQIGFkZHJlc3MgY2hhbmdlIG5vdGlmaWVyIHNjcmlwdDx3cHRiPmh0dHA6Ly9wYXJpby5ubzx3cHRiPlBhcmlvIFRlY2hub0Jsb2I%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2009/01/21/ip-address-change-notifier-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rename file name suffix to uppercase or lowercase</title>
		<link>http://pario.no/2008/10/24/rename-file-name-suffix-to-uppercase-or-lowercase/</link>
		<comments>http://pario.no/2008/10/24/rename-file-name-suffix-to-uppercase-or-lowercase/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 18:12:22 +0000</pubDate>
		<dc:creator>Hans-Henry Jakobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[lowercase]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[uppercase]]></category>

		<guid isPermaLink="false">http://pario.no/?p=781</guid>
		<description><![CDATA[This is a little oneliner to rename a files suffix from/to uppercase/lowercase. Rename a jpg suffix to JPG in the current folder # find -name "*.jpg" &#124; while read a; do mv "$a" "${a%%.jpg}.JPG" ; done The work JPG can be replaced by any other word :)]]></description>
			<content:encoded><![CDATA[<p>This is a little oneliner to rename a files suffix from/to uppercase/lowercase.</p>
<p>Rename a <strong>jpg</strong> suffix to <strong>JPG</strong> in the current folder</p>
<pre>
# find -name "*.jpg" | while read a; do mv "$a" "${a%%.jpg}.JPG" ; done</pre>
<p>The work JPG can be replaced by any other word :)</p>
<script type="text/javascript">var wordpress_toolbar_urls = [];var wordpress_toolbar_url = "http://pario.no/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "n";var wordpress_toolbar_hash = "aHR0cDovL3BhcmlvLm5vLzIwMDgvMTAvMjQvcmVuYW1lLWZpbGUtbmFtZS1zdWZmaXgtdG8tdXBwZXJjYXNlLW9yLWxvd2VyY2FzZS88d3B0Yj5SZW5hbWUgZmlsZSBuYW1lIHN1ZmZpeCB0byB1cHBlcmNhc2Ugb3IgbG93ZXJjYXNlPHdwdGI%2BaHR0cDovL3BhcmlvLm5vPHdwdGI%2BUGFyaW8gVGVjaG5vQmxvYg%3D%3D";</script>]]></content:encoded>
			<wfw:commentRss>http://pario.no/2008/10/24/rename-file-name-suffix-to-uppercase-or-lowercase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

