<?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>Wojciech Jamrozy blog &#187; Bash</title>
	<atom:link href="http://www.wojtekrj.net/category/bash-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wojtekrj.net</link>
	<description>Blog about computer science, programming and linux</description>
	<lastBuildDate>Sun, 23 Oct 2011 21:57:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[Bash] Script for monitoring content of website</title>
		<link>http://www.wojtekrj.net/2010/03/bash-script-for-monitoring-content-of-website/</link>
		<comments>http://www.wojtekrj.net/2010/03/bash-script-for-monitoring-content-of-website/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 11:56:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[monitoring]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=354</guid>
		<description><![CDATA[Imagine that you are waiting for marks from exam. Lecturer is going to publish them on his website, but you don&#8217;t know when. I&#8217;ve created following script, because I don&#8217;t like pressing F5 for hours You have to provide address of website, and if website changes, script will open firefox and show notification. 1 2 [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine that you are waiting for marks from exam. Lecturer is going to publish them on his website, but you don&#8217;t know when.<br />
I&#8217;ve created following script, because I don&#8217;t like pressing F5 for hours <img src='http://www.wojtekrj.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
You have to provide address of website, and if website changes, script will open firefox and show notification.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># Wojtek Jamrozy www.wojtekrj.net</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: $0 &lt;url of website&gt; &quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #007800;">hash</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> - <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> md5sum<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`wget -q -O - $1 | md5sum`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;<span style="color: #007800;">$hash</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		firefox <span style="color: #007800;">$1</span>
		notify-send <span style="color: #ff0000;">&quot;Change on the website $1&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Nothing has changed&quot;</span>
	<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">120</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;linkname=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2010%2F03%2Fbash-script-for-monitoring-content-of-website%2F&amp;title=%5BBash%5D%20Script%20for%20monitoring%20content%20of%20website" id="wpa2a_2">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2010/03/bash-script-for-monitoring-content-of-website/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[Bash,Linux] Very fast disk shredding/data erasure script</title>
		<link>http://www.wojtekrj.net/2009/09/bashlinux-very-fast-disk-shredingdata-erasure-script/</link>
		<comments>http://www.wojtekrj.net/2009/09/bashlinux-very-fast-disk-shredingdata-erasure-script/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 14:28:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[data erasure]]></category>
		<category><![CDATA[disk shreding]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=309</guid>
		<description><![CDATA[Before I have setted up my encrypted partitions I had to fill them with random sequention of data. I&#8217;ve noticed that dd if=/dev/urandom of=DEVICE is very slow. It has 3-4 MB/second on my computer. I wanted to make it faster. Here is my solution: 1. Create in tmpfs located in RAM memory large file (about [...]]]></description>
			<content:encoded><![CDATA[<p>Before I have setted up my encrypted partitions I had to fill them with random sequention of data.<br />
I&#8217;ve noticed that dd if=/dev/urandom of=DEVICE is very slow. It has 3-4 MB/second on my computer.<br />
I wanted to make it faster. Here is my solution:<br />
1. Create in tmpfs located in RAM memory large file (about 100 MB) made of pseudo-random sequence (/dev/urandom).<br />
2. Write this file from memory sequentially to the disk.<br />
Speed of this approach is even 34 MB/s &#8211; 10 times faster!!.<br />
Unfortunately, this aproach might not be as secure as dd if=/dev/urandom of=DEVICE<br />
Before you do anything backup your data and be sure what are you doing!!!<br />
My implementation:<span id="more-309"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># Author: Wojtek Jamrozy (www.wojtekrj.net)</span>
<span style="color: #666666; font-style: italic;"># BE SURE WHAT ARE YOU DOING - YOU CAN LOST IMPORTANT DATA</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: $0 &lt;name of device&gt;&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;You choose $1 device to shred&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Are you sure (it will destroy ALL data on this device)? Type upercase yes:&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #007800;">TMP_DIR</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>_tmpfs
<span style="color: #007800;">SIZE</span>=<span style="color: #000000;">100</span> <span style="color: #666666; font-style: italic;"># size of pattern in megabytes</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$yes</span>&quot;</span> = <span style="color: #ff0000;">&quot;YES&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Generating random pattern...&quot;</span>
	<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$TMP_DIR</span>
	<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-t</span> tmpfs  tmp <span style="color: #007800;">$TMP_DIR</span>
	<span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>urandom <span style="color: #007800;">of</span>=<span style="color: #007800;">$TMP_DIR</span><span style="color: #000000; font-weight: bold;">/</span>plik <span style="color: #007800;">bs</span>=<span style="color: #800000;">${SIZE}</span>MB <span style="color: #007800;">count</span>=<span style="color: #000000;">1</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Generating random pattern finished...&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting shreding $1&quot;</span>
	<span style="color: #007800;">before</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>	
		<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #007800;">$TMP_DIR</span><span style="color: #000000; font-weight: bold;">/</span>plik <span style="color: #007800;">of</span>=<span style="color: #007800;">$1</span> <span style="color: #007800;">bs</span>=<span style="color: #800000;">${SIZE}</span>MB <span style="color: #007800;">seek</span>=<span style="color: #007800;">$i</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
		<span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">break</span>
		<span style="color: #000000; font-weight: bold;">fi</span>
		<span style="color: #007800;">i</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>i+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #007800;">after</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$((i*SIZE)</span>)MB have been copied<span style="color: #000099; font-weight: bold;">\n</span>Average speed: <span style="color: #007800;">$((i*SIZE/(after-before+1)</span>)) MB/s&quot;</span>
	<span style="color: #000000; font-weight: bold;">done</span>
	<span style="color: #007800;">after</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Average speed: <span style="color: #007800;">$(((i+1)</span>*SIZE/(after-before+1))) MB/s&quot;</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$TMP_DIR</span><span style="color: #000000; font-weight: bold;">/</span>plik
	<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #007800;">$TMP_DIR</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-R</span> <span style="color: #007800;">$TMP_DIR</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;You haven't typed <span style="color: #000099; font-weight: bold;">\&quot;</span>YES<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\n</span>Exiting...&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;linkname=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Fbashlinux-very-fast-disk-shredingdata-erasure-script%2F&amp;title=%5BBash%2CLinux%5D%20Very%20fast%20disk%20shredding%2Fdata%20erasure%20script" id="wpa2a_4">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2009/09/bashlinux-very-fast-disk-shredingdata-erasure-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Linux] Random password generator</title>
		<link>http://www.wojtekrj.net/2009/09/linux-random-password-generator/</link>
		<comments>http://www.wojtekrj.net/2009/09/linux-random-password-generator/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 16:42:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[password generator]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=290</guid>
		<description><![CDATA[Here is a script for generating random alphanumeric passwords: #!/bin/bash # passwords.sh if &#91; $# != 2 &#93;; then echo &#34;usage: $0 &#60;length of passwords&#62; &#60;number of passwords&#62; &#34; exit 1 fi tr -cd '[:graph:]' &#60; /dev/urandom &#124; fold -w $1 &#124; head -$2]]></description>
			<content:encoded><![CDATA[<p>Here is a script for generating random alphanumeric passwords:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash </span>
<span style="color: #666666; font-style: italic;"># passwords.sh  </span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: $0 &lt;length of passwords&gt; &lt;number of passwords&gt; &quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-cd</span> <span style="color: #ff0000;">'[:graph:]'</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>urandom <span style="color: #000000; font-weight: bold;">|</span> fold <span style="color: #660033;">-w</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> -<span style="color: #007800;">$2</span></pre></div></div>

<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;linkname=%5BLinux%5D%20Random%20password%20generator" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F09%2Flinux-random-password-generator%2F&amp;title=%5BLinux%5D%20Random%20password%20generator" id="wpa2a_6">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2009/09/linux-random-password-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Bash] How to show information about dd progress / statistics</title>
		<link>http://www.wojtekrj.net/2009/08/bash-how-to-show-information-about-dd-progress-statistics/</link>
		<comments>http://www.wojtekrj.net/2009/08/bash-how-to-show-information-about-dd-progress-statistics/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 21:54:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[kill]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=265</guid>
		<description><![CDATA[dd is a great tool for low-level copying and conversion of raw data. It can be also used for data erasure. Unfortunately, it doesn&#8217;t show any information about progress of copying. Here is my little, but useful script: 1 2 3 4 5 6 7 8 9 10 #!/bin/bash # dd.sh Author: Wojtek Jamrozy (www.wojtekrj.net) [...]]]></description>
			<content:encoded><![CDATA[<p><em>dd</em> is a great tool for low-level copying and conversion of raw data. It can be also used for data erasure. Unfortunately, it doesn&#8217;t show any information about progress of copying.<br />
Here is my little, but useful script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash </span>
<span style="color: #666666; font-style: italic;"># dd.sh Author: Wojtek Jamrozy (www.wojtekrj.net)</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">$*</span> <span style="color: #000000; font-weight: bold;">&amp;</span> <span style="color: #007800;">pid</span>=<span style="color: #007800;">$!</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;/proc/<span style="color: #007800;">$pid</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-USR1</span> <span style="color: #007800;">$pid</span> 
	<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p><span id="more-265"></span><br />
Line 4 executes <em>dd </em> with arguments of <em>dd.sh</em> at the background, and stores PID of <em>dd</em> process in <em>$pid</em> variable<br />
In line 7 while checks if /proc/$pid exists. If exsists, process $pid is still running.<br />
Line 8 is executed every 10 secunds and tell <em>dd</em> to  show information about progress.</p>
<p>Example of usage:</p>
<p>
$ ./dd.sh if=/dev/zero of=/dev/null count=50000000<br />
11282170+0 przeczytanych recordów<br />
11282169+0 zapisanych recordów<br />
skopiowane 5776470528 bajtów (5,8 GB), 10,0174 s, 577 MB/s<br />
22557922+0 przeczytanych recordów<br />
22557922+0 zapisanych recordów<br />
skopiowane 11549656064 bajty (12 GB), 20,0196 s, 577 MB/s<br />
33852540+0 przeczytanych recordów<br />
33852540+0 zapisanych recordów<br />
skopiowane 17332500480 bajtów (17 GB), 30,0219 s, 577 MB/s<br />
45151438+0 przeczytanych recordów<br />
45151437+0 zapisanych recordów<br />
skopiowane 23117535744 bajty (23 GB), 40,024 s, 578 MB/s<br />
50000000+0 przeczytanych recordów<br />
50000000+0 zapisanych recordów<br />
skopiowane 25600000000 bajtów (26 GB), 44,321 s, 578 MB/s</p>
<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;linkname=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fbash-how-to-show-information-about-dd-progress-statistics%2F&amp;title=%5BBash%5D%20How%20to%20show%20information%20about%20dd%20progress%20%2F%20statistics" id="wpa2a_8">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2009/08/bash-how-to-show-information-about-dd-progress-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Ubuntu] Packages auto-purging script</title>
		<link>http://www.wojtekrj.net/2009/08/ubuntu-packages-auto-purging-script/</link>
		<comments>http://www.wojtekrj.net/2009/08/ubuntu-packages-auto-purging-script/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 17:02:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[purging]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=219</guid>
		<description><![CDATA[Here is my script for auto-purging of removed packages (the script deletes remaining configuration files of package) in Ubuntu: #!/bin/sh for i in `dpkg -l &#124; grep ^rc &#124; cut -f 3 -d ' '` do dpkg -P $i; done dpkg -l shows list of packages installed in system grep ^rc print all lines starting [...]]]></description>
			<content:encoded><![CDATA[<p>Here is my script for auto-purging of removed packages (the script deletes remaining configuration files of package) in Ubuntu:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> ^rc <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">' '</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-P</span> <span style="color: #007800;">$i</span>;
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p><span id="more-219"></span><br />
<em>dpkg -l</em>  shows list of packages installed in system<br />
<em>grep ^rc </em>   print all lines starting with &#8220;rc&#8221; (in this case print all lines with name of packages which configuration files are still in system)<br />
<em>cut -f 3 -d &#8216; &#8216;</em> Divides lines into fields using space as delimiter and prints 3rd field (in this case retrieve name of packages to delete)<br />
<em>dpkg -P package</em> purges <em>package</em><br />
This <a href="http://www.wojtekrj.net/2009/07/bash-how-to-iterate-over-lines-of-standard-output-of-command/">link</a> explains other things.<br />
Script can also be added to /etc/crontab as:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">09 <span style="color: #000000;">18</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> root <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> ^rc <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">' '</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-P</span> <span style="color: #007800;">$i</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>Script will be executed with root privileges everyday at 18:09.</p>
<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;linkname=%5BUbuntu%5D%20Packages%20auto-purging%20script" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F08%2Fubuntu-packages-auto-purging-script%2F&amp;title=%5BUbuntu%5D%20Packages%20auto-purging%20script" id="wpa2a_10">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2009/08/ubuntu-packages-auto-purging-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Bash] How to iterate over lines of standard output of command</title>
		<link>http://www.wojtekrj.net/2009/07/bash-how-to-iterate-over-lines-of-standard-output-of-command/</link>
		<comments>http://www.wojtekrj.net/2009/07/bash-how-to-iterate-over-lines-of-standard-output-of-command/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 16:27:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=209</guid>
		<description><![CDATA[It&#8217;s very easy to iterate over lines of standard output of command. Here is an example: #!/bin/sh &#160; for i in `seq 0 5 15` do echo $i done The output is: 0 5 10 15 seq 0 5 15 iterates from 0 to 15 with step 5 `command` executes command and return its standard [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s very easy to iterate over lines of standard output of command.<span id="more-209"></span></p>
<p>Here is an example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">0</span> <span style="color: #000000;">5</span> <span style="color: #000000;">15</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>The output is:</p>
<pre>0
5
10
15</pre>
<p><em>seq 0 5 15</em> iterates from 0 to 15 with step 5</p>
<p><em>`command`</em> executes command and return its standard output</p>
<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;linkname=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F07%2Fbash-how-to-iterate-over-lines-of-standard-output-of-command%2F&amp;title=%5BBash%5D%20How%20to%20iterate%20over%20lines%20of%20standard%20output%20of%20command" id="wpa2a_12">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2009/07/bash-how-to-iterate-over-lines-of-standard-output-of-command/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[Bash] Making program working after close of SSH session</title>
		<link>http://www.wojtekrj.net/2009/04/bash-making-program-working-after-close-of-ssh-session/</link>
		<comments>http://www.wojtekrj.net/2009/04/bash-making-program-working-after-close-of-ssh-session/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 12:41:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=159</guid>
		<description><![CDATA[If you want to make your program working even if ssh session is close, you can use following command: nohup program &#62; output If you close SSH session (or terminal), program will be still executed and standard output of program will be send to output file.]]></description>
			<content:encoded><![CDATA[<p>If you want to make your program working even if ssh session is close, you can use following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">nohup</span> program <span style="color: #000000; font-weight: bold;">&gt;</span> output</pre></div></div>

<p>If you close SSH session (or terminal), <em>program</em> will be still executed and standard output of <em>program</em> will be send to <em>output</em> file.</p>
<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;linkname=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-making-program-working-after-close-of-ssh-session%2F&amp;title=%5BBash%5D%20Making%20program%20working%20after%20close%20of%20SSH%20session" id="wpa2a_14">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2009/04/bash-making-program-working-after-close-of-ssh-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Bash] How to kill program after n seconds</title>
		<link>http://www.wojtekrj.net/2009/04/bash-how-to-kill-program-after-n-seconds/</link>
		<comments>http://www.wojtekrj.net/2009/04/bash-how-to-kill-program-after-n-seconds/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 17:11:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=152</guid>
		<description><![CDATA[I&#8217;m sorry that I haven&#8217;t written for such a long time. It&#8217;s going to change:) We have a program, which can suspend our terminal. We want to be sure, that program won&#8217;t be executed for more than n seconds. Here is a solution: &#40;&#40;sleep 10 &#38;&#38; killall top&#41;&#38;&#41;; top Explanation: sleep 10 is executed for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sorry that I haven&#8217;t written for such a long time. It&#8217;s going to change:)</p>
<p>We have a program, which can suspend our terminal. We want to be sure, that program won&#8217;t be executed for more than n seconds. Here is a solution:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">killall</span> top<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">&amp;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; top</pre></div></div>

<p>Explanation:<br />
<em>sleep 10 </em>is executed for 10 seconds and then exit (you can use <em>sleep n </em>if you want<em> sleep</em> to be executed for n seconds</p>
<p><em>killall top</em> terminates all processes named &#8220;top&#8221;</p>
<p><em>top </em>- is example of program; top shows information about processes in your system</p>
<p><em>command1 &amp;&amp; command2</em> &#8211; executes <em>command1</em> and then, if <em>command1</em> has succedeed, <em>command2</em></p>
<p><em>command</em> &amp; &#8211; executes <em>command</em> at the background of terminal</p>
<p><em>command1; command2</em> &#8211; executes <em>command1</em> and <em>command2</em>, even if<em> command1 hasn&#8217;t succedeed<br />
</em></p>
<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;linkname=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2009%2F04%2Fbash-how-to-kill-program-after-n-seconds%2F&amp;title=%5BBash%5D%20How%20to%20kill%20program%20after%20n%20seconds" id="wpa2a_16">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2009/04/bash-how-to-kill-program-after-n-seconds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Bash] Text file manipulation</title>
		<link>http://www.wojtekrj.net/2008/08/bash-text-file-manipulation/</link>
		<comments>http://www.wojtekrj.net/2008/08/bash-text-file-manipulation/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 20:44:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[text file]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=84</guid>
		<description><![CDATA[I&#8217;m presenting here some text file manipulation commands with examples of usage. I want to enlarge on cat, tac, uniq, sort, head, tail, tr, wc and cut. Firstly, let&#8217;s create file named test.txt with following content: 1,AAAA,NNN 11,BBB,OOO 21,CCC,PPP 12,DDD,RRR 23,EEE,SSS 14,FFF,TTT 14,FFF,TTT 14,FFF,TTT 4,JJJJ,XXX 6,KKKK,YYY 5,LLLL,ZZZ 7,MMMM,AAA and test2.txt: 1000,aaa,bbb 1000,aaa,bbb Secondly, when you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m presenting here some text file manipulation commands with examples of usage. I want to enlarge on <strong>cat</strong>, <strong>tac</strong>,<strong> uniq</strong>, <strong>sort</strong>, <strong>head</strong>, <strong>tail</strong>, <strong>tr</strong>, <strong>wc</strong> and <strong>cut</strong>.<span id="more-84"></span><br />
Firstly, let&#8217;s create file named test.txt with following content:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">7</span>,MMMM,AAA</pre></div></div>

<p>and test2.txt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">1000</span>,aaa,bbb
<span style="color: #000000;">1000</span>,aaa,bbb</pre></div></div>

<p>Secondly, when you write:<br />
<em>command1 | command2 | command 3</em> &#8211; the standard output of <em>command1</em> is the standard input of <em>command2</em> and the standard output of <em>command2</em> is the standard input of <em>command3</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;test&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cat</span>
<span style="color: #7a0874; font-weight: bold;">test</span></pre></div></div>

<p><em>command1 &amp;&amp; command2</em> &#8211; if <em>command1</em> is successfully executed, system will execute<em> command2</em></p>
<p><em>command1 &lt; infile &gt; outfile </em> &#8211; content of <em>infile</em> is standard input of<em> command1</em> and the output of <em>command1 </em>is saved to <em>outfile</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&lt;</span> test.txt <span style="color: #000000; font-weight: bold;">&gt;</span> test3.txt <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> test3.txt
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">7</span>,MMMM,AAA</pre></div></div>

<p>The file will be used to show working of commands:</p>
<p><strong>cat</strong> &#8211; without arguments it just copies standard input to standard output (if you use keyboard as standard input, type Ctrl+D when you finish &#8211; <strong>cat</strong> will treat it as EOF (end of file) character). If it has one argument, it will print content of file, which name is the first argument. If it has more arguments, it will print contents of files in order they apeared as arguments.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> test.txt
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">7</span>,MMMM,AAA
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> test2.txt
<span style="color: #000000;">1000</span>,aaa,bbb
<span style="color: #000000;">1000</span>,aaa,bbb
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> test.txt test2.txt
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">7</span>,MMMM,AAA
<span style="color: #000000;">1000</span>,aaa,bbb
<span style="color: #000000;">1000</span>,aaa,bbb</pre></div></div>

<p><strong>tac</strong> &#8211; it works like cat, but prints lines of files in reversed order</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">tac</span> test.txt
<span style="color: #000000;">7</span>,MMMM,AAA
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">1</span>,AAAA,NNN
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">tac</span> test.txt test2.txt
<span style="color: #000000;">7</span>,MMMM,AAA
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">1000</span>,aaa,bbb
<span style="color: #000000;">1000</span>,aaa,bbb</pre></div></div>

<p><strong>uniq</strong> &#8211; it prints content of file without subsequent same lines</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">uniq</span> test.txt
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">7</span>,MMMM,AAA
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">uniq</span> test2.txt
<span style="color: #000000;">1000</span>,aaa,bbb</pre></div></div>

<p><strong>sort</strong> &#8211; it sorts lines of file in lexicographical order. If command is executed with -n option, it will compare numbers at the begining of each line.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">sort</span> test.txt
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">7</span>,MMMM,AAA
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span> test.txt
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">7</span>,MMMM,AAA
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">23</span>,EEE,SSS</pre></div></div>

<p><strong>nl </strong>- add a number before each line of file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">nl</span>  test.txt
<span style="color: #000000;">1</span>	<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">2</span>	<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">3</span>	<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">4</span>	<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">5</span>	<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">6</span>	<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">7</span>	<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">8</span>	<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">9</span>	<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">10</span>	<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">11</span>	<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">12</span>	<span style="color: #000000;">7</span>,MMMM,AAA</pre></div></div>

<p><strong>head</strong> &#8211; prints first 10 lines of file. If it is executed with option -N, when N is a number, it will print first N lines of file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">head</span> test.txt
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">6</span>,KKKK,YYY
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-3</span> test.txt
<span style="color: #000000;">1</span>,AAAA,NNN
<span style="color: #000000;">11</span>,BBB,OOO
<span style="color: #000000;">21</span>,CCC,PPP
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-1</span> test.txt
<span style="color: #000000;">1</span>,AAAA,NNN</pre></div></div>

<p><strong>tail</strong> &#8211; similar to head, but prints last lines</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">tail</span> test.txt
<span style="color: #000000;">21</span>,CCC,PPP
<span style="color: #000000;">12</span>,DDD,RRR
<span style="color: #000000;">23</span>,EEE,SSS
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">14</span>,FFF,TTT
<span style="color: #000000;">4</span>,JJJJ,XXX
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">7</span>,MMMM,AAA
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-3</span> test.txt
<span style="color: #000000;">6</span>,KKKK,YYY
<span style="color: #000000;">5</span>,LLLL,ZZZ
<span style="color: #000000;">7</span>,MMMM,AAA
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-1</span> test.txt
<span style="color: #000000;">7</span>,MMMM,AAA</pre></div></div>

<p><strong>wc </strong>- it counts number of characters, words and lines of file. It can print statistics only for characters (option -c), words (-w) and lines (-l).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">wc</span> test.txt
<span style="color: #000000;">12</span>  <span style="color: #000000;">12</span> <span style="color: #000000;">132</span> test.txt
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-w</span> test.txt
<span style="color: #000000;">12</span> test.txt
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-l</span> test.txt
<span style="color: #000000;">12</span> test.txt
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-c</span> test.txt
<span style="color: #000000;">132</span> test.txt</pre></div></div>

<p><strong>tr</strong> &#8211; read content from standard input and write to standard output deleting or changing some characters:<br />
<em>tr string1 string2</em> replaces first character from <em>string1 </em>to first character from <em>string2</em>, second to second, third to third, etc.<br />
<em>tr -d string1</em> deletes every occurrence of characters from<em> string1</em><br />
<em> tr -cd string1</em> deletes every occurence of characters, which are NOT from <em>string1</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> test2.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> abc ABC
<span style="color: #000000;">1000</span>,AAA,BBB
<span style="color: #000000;">1000</span>,AAA,BBB
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> test2.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-d</span> abc
<span style="color: #000000;">1000</span>,,
<span style="color: #000000;">1000</span>,,
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> test2.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #660033;">-cd</span> abc
aaabbbaaabbb</pre></div></div>

<p><strong>cut </strong> &#8211; prints only part of line. Each line is constructed of fields separated by special character called separator.<br />
Let&#8217;s consider line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">1</span>,AAAA,NNN</pre></div></div>

<p>The separator is character &#8220;,&#8221;, there are 3 fields: first &#8211; &#8220;1&#8243;, second &#8211; &#8220;AAAA&#8221; and third &#8220;NNN&#8221;.<strong> cut</strong> has following syntax:<br />
<em>cut -d C -f N text.txt</em> where C is separator and N is number of field to display</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span> , <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span>-<span style="color: #000000;">2</span> test.txt
<span style="color: #000000;">1</span>,AAAA
<span style="color: #000000;">11</span>,BBB
<span style="color: #000000;">21</span>,CCC
<span style="color: #000000;">12</span>,DDD
<span style="color: #000000;">23</span>,EEE
<span style="color: #000000;">14</span>,FFF
<span style="color: #000000;">14</span>,FFF
<span style="color: #000000;">14</span>,FFF
<span style="color: #000000;">4</span>,JJJJ
<span style="color: #000000;">6</span>,KKKK
<span style="color: #000000;">5</span>,LLLL
<span style="color: #000000;">7</span>,MMMM
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span> , <span style="color: #660033;">-f</span> <span style="color: #000000;">1</span>,<span style="color: #000000;">3</span> test.txt
<span style="color: #000000;">1</span>,NNN
<span style="color: #000000;">11</span>,OOO
<span style="color: #000000;">21</span>,PPP
<span style="color: #000000;">12</span>,RRR
<span style="color: #000000;">23</span>,SSS
<span style="color: #000000;">14</span>,TTT
<span style="color: #000000;">14</span>,TTT
<span style="color: #000000;">14</span>,TTT
<span style="color: #000000;">4</span>,XXX
<span style="color: #000000;">6</span>,YYY
<span style="color: #000000;">5</span>,ZZZ
<span style="color: #000000;">7</span>,AAA</pre></div></div>

<p>If you write after -f N-M fields from N to M will be printed. If N,M &#8211; N-th and M-th field will be printed.</p>
<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;linkname=%5BBash%5D%20Text%20file%20manipulation" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-text-file-manipulation%2F&amp;title=%5BBash%5D%20Text%20file%20manipulation" id="wpa2a_18">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2008/08/bash-text-file-manipulation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[Bash] Script to swap contents of files</title>
		<link>http://www.wojtekrj.net/2008/08/bash-script-to-swap-contents-of-files/</link>
		<comments>http://www.wojtekrj.net/2008/08/bash-script-to-swap-contents-of-files/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 11:45:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[file manipulation]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[swap]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=51</guid>
		<description><![CDATA[There are two files (for example called „f1” and „f2”). We want to swap contents of these files. Here is an easy bash script, which solves this problem: #!/bin/sh # Created by Wojtek Jamrozy (www.wojtekrj.net) mv $1 cop_$1 mv $2 $1 mv cop_$1 $2 Download this file or make a text file with this content [...]]]></description>
			<content:encoded><![CDATA[<p>There are two files (for example called „f1” and „f2”). We want to swap contents of these files. Here is an easy bash script, which solves this problem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># Created by Wojtek Jamrozy (www.wojtekrj.net)</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$1</span> cop_<span style="color: #007800;">$1</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$2</span> <span style="color: #007800;">$1</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> cop_<span style="color: #007800;">$1</span> <span style="color: #007800;">$2</span></pre></div></div>

<p>Note: There is a file embedded within this post, please visit this post to download the file.<span id="more-51"></span><br />
Download this file or make a text file with this content named <em>swap </em>and make it executable with command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x swap</pre></div></div>

<p>Then copy this file to <em>/usr/local/bin</em> directory using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> swap <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin</pre></div></div>

<p>If you have this file in <em>/usr/local/bin</em> directory (or any other included in<em> $PATH</em> environment variable – command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$PATH</span></pre></div></div>

<p>will show other directories) you don&#8217;t have to write full path to script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">swap f1 f2</pre></div></div>

<p>will swap contents of files f1 and f2.<br />
Example of usage in shell:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;File 1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file1 <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;File 2&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> file2
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file1
File <span style="color: #000000;">1</span>
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file2
File <span style="color: #000000;">2</span>
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ swap file1 file2
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file1
File <span style="color: #000000;">2</span>
wojtekrj<span style="color: #000000; font-weight: bold;">@</span>wojtek-laptop:~$ <span style="color: #c20cb9; font-weight: bold;">cat</span> file2
File <span style="color: #000000;">1</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span></pre></div></div>

<p>is a standard header, which helps bash shell recognize file as a bash script.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> file1 file2</pre></div></div>

<p>a command, which rename/move file from path <em>file1</em> to <em>file2</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #c20cb9; font-weight: bold;">file</span></pre></div></div>

<p>show content of <em>file</em></p>
<p>When the script is executed with two arguments (like in example – <em>swap f1 f2</em>), $1 will contain first  argument &#8211; f1, and $2 second – f2.<br />
When $1 or $2 appears in script, it&#8217;s replaced with content of $1 or $2:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$1</span> cop_<span style="color: #007800;">$1</span> -<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> f1 cop_f1
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$2</span> <span style="color: #007800;">$1</span> -<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> f2 f1</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> text_to_display</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;text_to_display&quot;</span></pre></div></div>

<p>commands will show text <em>text_to_display</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">file</span></pre></div></div>

<p>will save output of <em>command</em> to file <em>file</em></p>
<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;linkname=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F08%2Fbash-script-to-swap-contents-of-files%2F&amp;title=%5BBash%5D%20Script%20to%20swap%20contents%20of%20files" id="wpa2a_20">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2008/08/bash-script-to-swap-contents-of-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

