<?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>Solid State Raam &#187; Bash</title>
	<atom:link href="http://solidstateraam.com/category/linux/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://solidstateraam.com</link>
	<description>Explorations (and exploitations) of the digital world by one of its many netizens.</description>
	<lastBuildDate>Sat, 17 Dec 2011 20:18:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>MAC Address Validation Regex with egrep</title>
		<link>http://solidstateraam.com/mac-address-validation-regex-with-egrep/</link>
		<comments>http://solidstateraam.com/mac-address-validation-regex-with-egrep/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 00:45:08 +0000</pubDate>
		<dc:creator>Raam</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://solidstateraam.com/?p=334</guid>
		<description><![CDATA[I needed an easy way to validate a MAC address in a bash script that generated a unique hostname based on the MAC address of the system. Read about how I solved the problem using a regular expression and egrep.]]></description>
			<content:encoded><![CDATA[<p>I needed an easy way to validate a MAC address in a bash script that generated a unique hostname based on the MAC address of the system. This gem did the trick:</p>
<pre class="brush: bash; title: ; notranslate">
echo &quot;00:11:24:3e:a5:78&quot; | egrep &quot;^([0-9a-fA-F]{2}\:){5}[0-9a-fA-F]{2}$&quot;
</pre>
<p>In the event that there was a problem getting the MAC address (e.g., faulty NIC or unstable device driver), I generate a random hostname instead of basing the hostname generation on the MAC. Here&#8217;s how I validated the MAC in the script:</p>
<pre class="brush: bash; title: ; notranslate">
if [ `echo $ACTIVE_INTERFACE_MAC | egrep &quot;^([0-9a-fA-F]{2}\:){5}[0-9a-fA-F]{2}$&quot;` ]; then
	# generate unique hostname based on MAC
else
	# generate random-character hostname
fi
</pre>
]]></content:encoded>
			<wfw:commentRss>http://solidstateraam.com/mac-address-validation-regex-with-egrep/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

