<?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>Experts Heaven &#187; Unix</title>
	<atom:link href="http://www.expertsheaven.com/category/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.expertsheaven.com</link>
	<description>Invent, Innovate and Inspire</description>
	<lastBuildDate>Sun, 18 Oct 2009 18:47:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Split File Based on Line Numbers in UNIX</title>
		<link>http://www.expertsheaven.com/split-file-based-on-line-numbers-in-unix/</link>
		<comments>http://www.expertsheaven.com/split-file-based-on-line-numbers-in-unix/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 09:54:56 +0000</pubDate>
		<dc:creator>Frederick Tybalt</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[lines]]></category>
		<category><![CDATA[records]]></category>
		<category><![CDATA[split]]></category>

		<guid isPermaLink="false">http://www.expertsheaven.com/?p=149</guid>
		<description><![CDATA[This script will be useful if you require to split a huge file based on number of lines or records. Normal file splitters available in the market split the file based on the size (byte, KB, MB) which cannot be used to split based on number of lines or records. Steps to use the script: [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;source=BenedictHerold&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>This script will be useful if you require to split a huge file based on number of lines or records. Normal file splitters available in the market split the file based on the size (byte, KB, MB) which cannot be used to split based on number of lines or records.</p>
<p><span style="font-size: medium;"><strong>Steps to use the script:</strong></span></p>
<p>1. Save the below script as lsplit.ksh<br />
<code>propDIR=./<br />
propFile=$propDIR/SSNRange.txt.prop<br />
inpFile=$1<br />
date<br />
startLineNo=1<br />
count=1<br />
while read line<br />
do<br />
startLineNo=`echo $line | cut -f1 -d,`<br />
endLineNo=`echo $line | cut -f2 -d,`<br />
if [ "$endLineNo" != "" -a "$startLineNo" != "" ]; then<br />
echo "Cut here from $startLineNo to $endLineNo"<br />
sed -n "$startLineNo","$endLineNo"p $inpFile &gt; $inpFile.split.$count<br />
count=`expr $count + 1`<br />
fi<br />
done &lt; $propFile<br />
date<br />
</code></p>
<p>2. Create a properties file SSNRange.txt.prop which would contain the range of records or lines. Example of properties file is as follows<br />
<code>1,400<br />
401,1504<br />
1505, 7000</code></p>
<p>3. Run the script<br />
<code>$ lsplit.ksh infile.txt</code></p>
<p>4. Three output files will be created</p>
<ul>
<li>infile.txt.split.1 &#8211;&gt; Creates a file with first 400 lines</li>
<li>infile.txt.split.2 &#8211;&gt; Creates a file with lines starting from 401 to 1504</li>
<li>infile.txt.split.3 &#8211;&gt; Creates a file with lines starting from 1505 to 7000</li>
</ul>
<p><span style="font-size: medium;"><strong>Advantages of this script:</strong></span></p>
<ul>
<li>File is split based on line numbers are records.</li>
<li>No manual editing is required the correct the first and last records</li>
<li>Easy to handle it in batch</li>
</ul>
<p><strong>Courtesy</strong>: <em>Santhosh Fabian</em></p>



Share and Enjoy:


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;title=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX&amp;bodytext=This%20script%20will%20be%20useful%20if%20you%20require%20to%20split%20a%20huge%20file%20based%20on%20number%20of%20lines%20or%20records.%20Normal%20file%20splitters%20available%20in%20the%20market%20split%20the%20file%20based%20on%20the%20size%20%28byte%2C%20KB%2C%20MB%29%20which%20cannot%20be%20used%20to%20split%20based%20on%20number%20of%20lines%20o" title="Digg"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;title=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX&amp;notes=This%20script%20will%20be%20useful%20if%20you%20require%20to%20split%20a%20huge%20file%20based%20on%20number%20of%20lines%20or%20records.%20Normal%20file%20splitters%20available%20in%20the%20market%20split%20the%20file%20based%20on%20the%20size%20%28byte%2C%20KB%2C%20MB%29%20which%20cannot%20be%20used%20to%20split%20based%20on%20number%20of%20lines%20o" title="del.icio.us"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;t=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX" title="Facebook"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;title=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX&amp;annotation=This%20script%20will%20be%20useful%20if%20you%20require%20to%20split%20a%20huge%20file%20based%20on%20number%20of%20lines%20or%20records.%20Normal%20file%20splitters%20available%20in%20the%20market%20split%20the%20file%20based%20on%20the%20size%20%28byte%2C%20KB%2C%20MB%29%20which%20cannot%20be%20used%20to%20split%20based%20on%20number%20of%20lines%20o" title="Google Bookmarks"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX&amp;body=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F" title="email"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;partner=sociable" title="Print"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;title=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX" title="Reddit"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.sphere.com/search?q=sphereit:http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;title=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX" title="SphereIt"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/sphere.png" title="SphereIt" alt="SphereIt" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F&amp;title=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX" title="StumbleUpon"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F" title="IndianPad"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=Split%20File%20Based%20on%20Line%20Numbers%20in%20UNIX%20-%20http%3A%2F%2Fwww.expertsheaven.com%2Fsplit-file-based-on-line-numbers-in-unix%2F" title="Twitter"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/><br/><a href='http://wordpress.org/extend/plugins/mystat/'><img src='http://www.expertsheaven.com/wp-content/plugins/mystat/images/admin.png' style='vertical-align:middle;' title='myStat statistic for WordPress' border='0' /></a> Unique visitors to post: <b>90</b><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.expertsheaven.com/split-file-based-on-line-numbers-in-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to close a telnet session without terminating the foreground process which is running</title>
		<link>http://www.expertsheaven.com/how-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running/</link>
		<comments>http://www.expertsheaven.com/how-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 16:58:46 +0000</pubDate>
		<dc:creator>Frederick Tybalt</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://howto.expertsheaven.com/?p=100</guid>
		<description><![CDATA[Finally have found out a way to terminate the telnet session with out killing the foreground process which is running. Anyone struck with the above situation can follow this Assume a script &#8220;script1&#8243; is running in the foreground for a long time and this script needs to be retained even if the telnet session is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;source=BenedictHerold&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Finally have found out a way to terminate the telnet session with out killing the foreground process which is running. Anyone struck with the above situation can follow this <img src='http://www.expertsheaven.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Assume a script &#8220;script1&#8243; is running in the foreground for a long time and this script needs to be retained even if the telnet session is closed. Here are the steps which needs to be followed.</p>
<p><strong>1.</strong> On the telnet screen press &lt;CTRL + Z&gt;. This will temporarily stop the script or process to run.<br />
<code><br />
<em>$ ./script1.ksh<br />
[1] + Stopped (SIGTSTP)        ./script1.ksh</em></code></p>
<p><strong>2.</strong> Type in the command &#8220;bg&#8221; to run the process in background</p>
<p><em><code>$ bg<br />
[1]     ./script1.ksh&amp;</code></em></p>
<p><strong>3.</strong> Identify the session process ID. This can be done by giving the &#8220;ps&#8221; command in the prompt.</p>
<p><em><code>$  ps<br />
PID      TTY   TIME  CMD<br />
4882522  pts/7  0:00 ps<br />
4984988  pts/7  0:00 -sh</code></em></p>
<p><strong>4.</strong> Identify the PID of the script which is is shifted to background. In our case &#8220;script1&#8243; This can be done by ps command piped with grep as below.<br />
<code><br />
<em>$ ps -ef | grep script1.ksh<br />
user1 4399240 4984988   0 08:57:49  pts/7  0:00 grep script1.ksh<br />
user1 5029960 4829226   0 07:57:23      -  0:00 /usr/lpp/ars/bin/script1.ksh</em></code></p>
<p><strong>5.</strong> Now with all the PID&#8217;s collected, use &#8220;nohup&#8221; command<br />
<code><br />
<em>$ nohup -p 4984988<br />
$ nohup -p 5029960</em></code></p>
<p>This will make the script or process not to be terminated even if the telnet session is closed.</p>
<p>NB: The telnet session process 4984988, will be running at the background unless it is killed.</p>
<p><strong>Courtesy:</strong> Santhosh Fabian</p>



Share and Enjoy:


	<a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;title=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running&amp;bodytext=Finally%20have%20found%20out%20a%20way%20to%20terminate%20the%20telnet%20session%20with%20out%20killing%20the%20foreground%20process%20which%20is%20running.%20Anyone%20struck%20with%20the%20above%20situation%20can%20follow%20this%20%3A%29%0D%0A%0D%0AAssume%20a%20script%20%22script1%22%20is%20running%20in%20the%20foreground%20for%20a%20long%20time" title="Digg"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;title=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running&amp;notes=Finally%20have%20found%20out%20a%20way%20to%20terminate%20the%20telnet%20session%20with%20out%20killing%20the%20foreground%20process%20which%20is%20running.%20Anyone%20struck%20with%20the%20above%20situation%20can%20follow%20this%20%3A%29%0D%0A%0D%0AAssume%20a%20script%20%22script1%22%20is%20running%20in%20the%20foreground%20for%20a%20long%20time" title="del.icio.us"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;t=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running" title="Facebook"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;title=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running&amp;annotation=Finally%20have%20found%20out%20a%20way%20to%20terminate%20the%20telnet%20session%20with%20out%20killing%20the%20foreground%20process%20which%20is%20running.%20Anyone%20struck%20with%20the%20above%20situation%20can%20follow%20this%20%3A%29%0D%0A%0D%0AAssume%20a%20script%20%22script1%22%20is%20running%20in%20the%20foreground%20for%20a%20long%20time" title="Google Bookmarks"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="mailto:?subject=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running&amp;body=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F" title="email"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;partner=sociable" title="Print"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;title=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running" title="Reddit"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.sphere.com/search?q=sphereit:http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;title=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running" title="SphereIt"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/sphere.png" title="SphereIt" alt="SphereIt" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F&amp;title=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running" title="StumbleUpon"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F" title="IndianPad"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a>
	<a rel="nofollow"  href="http://twitter.com/home?status=How%20to%20close%20a%20telnet%20session%20without%20terminating%20the%20foreground%20process%20which%20is%20running%20-%20http%3A%2F%2Fwww.expertsheaven.com%2Fhow-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running%2F" title="Twitter"><img src="http://www.expertsheaven.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>


<br/><br/><br/><a href='http://wordpress.org/extend/plugins/mystat/'><img src='http://www.expertsheaven.com/wp-content/plugins/mystat/images/admin.png' style='vertical-align:middle;' title='myStat statistic for WordPress' border='0' /></a> Unique visitors to post: <b>351</b><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.expertsheaven.com/how-to-close-a-telnet-session-without-terminating-the-foreground-process-which-is-running/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	<img style='margin:0;padding:0;border:0;' width='1px' height='1px' src="http://www.expertsheaven.com/wp-content/plugins/mystat/mystat.php?act=time_load&id=42503&rnd=1099251499" /></channel>
</rss>
