<?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>ScriptBits, Little Bits Of Code You Cannot Live Without</title>
	<atom:link href="http://www.scriptbits.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptbits.net</link>
	<description>What are you coding?</description>
	<lastBuildDate>Mon, 13 Jul 2009 14:00:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AWK Scripts and Examples</title>
		<link>http://www.scriptbits.net/2009/07/awk-scripts-and-examples/</link>
		<comments>http://www.scriptbits.net/2009/07/awk-scripts-and-examples/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 12:41:45 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/?p=162</guid>
		<description><![CDATA[As promised, here is the AWK cheat sheet.  It also was originally published by eric and can be seen at his site.
As with the the sed tutorial, I'd like to add to it with mine and any readers comments and/or suggestions.  Enjoy.




FILE SPACING:
 # double space a file
 awk '1;{print ""}'
 awk 'BEGIN{ORS="\n\n"};1'
 [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here is the AWK cheat sheet.  It also was originally published by eric and can be seen at <a href="http://www.pement.org/awk/awk1line.txt">his site</a>.</p>
<p>As with the the <a href="http://www.scriptbits.net/2009/07/sed-one-liners/">sed tutorial</a>, I'd like to add to it with mine and any readers comments and/or suggestions.  Enjoy.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>FILE SPACING:</p>
<p> # double space a file<br />
 awk '1;{print ""}'<br />
 awk 'BEGIN{ORS="\n\n"};1'</p>
<p> # double space a file which already has blank lines in it. Output file<br />
 # should contain no more than one blank line between lines of text.<br />
 # NOTE: On Unix systems, DOS lines which have only CRLF (\r\n) are<br />
 # often treated as non-blank, and thus 'NF' alone will return TRUE.<br />
 awk 'NF{print $0 "\n"}'</p>
<p> # triple space a file<br />
 awk '1;{print "\n"}'</p>
<p>NUMBERING AND CALCULATIONS:</p>
<p> # precede each line by its line number FOR THAT FILE (left alignment).<br />
 # Using a tab (\t) instead of space will preserve margins.<br />
 awk '{print FNR "\t" $0}' files*</p>
<p> # precede each line by its line number FOR ALL FILES TOGETHER, with tab.<br />
 awk '{print NR "\t" $0}' files*</p>
<p> # number each line of a file (number on left, right-aligned)<br />
 # Double the percent signs if typing from the DOS command prompt.<br />
 awk '{printf("%5d : %s\n", NR,$0)}'</p>
<p> # number each line of file, but only print numbers if line is not blank<br />
 # Remember caveats about Unix treatment of \r (mentioned above)<br />
 awk 'NF{$0=++a " :" $0};1'<br />
 awk '{print (NF? ++a " :" :"") $0}'</p>
<p> # count lines (emulates "wc -l")<br />
 awk 'END{print NR}'</p>
<p> # print the sums of the fields of every line<br />
 awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}'</p>
<p> # add all fields in all lines and print the sum<br />
 awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'</p>
<p> # print every line after replacing each field with its absolute value<br />
 awk '{for (i=1; i<=NF; i++) if ($i < 0) $i = -$i; print }'<br />
 awk '{for (i=1; i<=NF; i++) $i = ($i < 0) ? -$i : $i; print }'</p>
<p> # print the total number of fields ("words") in all lines<br />
 awk '{ total = total + NF }; END {print total}' file</p>
<p> # print the total number of lines that contain "Beth"<br />
 awk '/Beth/{n++}; END {print n+0}' file</p>
<p> # print the largest first field and the line that contains it<br />
 # Intended for finding the longest string in field #1<br />
 awk '$1 > max {max=$1; maxline=$0}; END{ print max, maxline}'</p>
<p> # print the number of fields in each line, followed by the line<br />
 awk '{ print NF ":" $0 } '</p>
<p> # print the last field of each line<br />
 awk '{ print $NF }'</p>
<p> # print the last field of the last line<br />
 awk '{ field = $NF }; END{ print field }'</p>
<p> # print every line with more than 4 fields<br />
 awk 'NF > 4'</p>
<p> # print every line where the value of the last field is > 4<br />
 awk '$NF > 4'</p>
<p>STRING CREATION:</p>
<p> # create a string of a specific length (e.g., generate 513 spaces)<br />
 awk 'BEGIN{while (a++<513) s=s " "; print s}'</p>
<p> # insert a string of specific length at a certain character position<br />
 # Example: insert 49 spaces after column #6 of each input line.<br />
 gawk --re-interval 'BEGIN{while(a++<49)s=s " "};{sub(/^.{6}/,"&#038;" s)};1'</p>
<p>ARRAY CREATION:</p>
<p> # These next 2 entries are not one-line scripts, but the technique<br />
 # is so handy that it merits inclusion here.</p>
<p> # create an array named "month", indexed by numbers, so that month[1]<br />
 # is 'Jan', month[2] is 'Feb', month[3] is 'Mar' and so on.<br />
 split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")</p>
<p> # create an array named "mdigit", indexed by strings, so that<br />
 # mdigit["Jan"] is 1, mdigit["Feb"] is 2, etc. Requires "month" array<br />
 for (i=1; i<=12; i++) mdigit[month[i]] = i</p>
<p>SELECTIVE PRINTING OF CERTAIN LINES:</p>
<p> # print first 10 lines of file (emulates behavior of "head")<br />
 awk 'NR < 11'</p>
<p> # print first line of file (emulates "head -1")<br />
 awk 'NR>1{exit};1'</p>
<p>  # print the last 2 lines of a file (emulates "tail -2")<br />
 awk '{y=x "\n" $0; x=$0};END{print y}'</p>
<p> # print the last line of a file (emulates "tail -1")<br />
 awk 'END{print}'</p>
<p> # print only lines which match regular expression (emulates "grep")<br />
 awk '/regex/'</p>
<p> # print only lines which do NOT match regex (emulates "grep -v")<br />
 awk '!/regex/'</p>
<p> # print any line where field #5 is equal to "abc123"<br />
 awk '$5 == "abc123"'</p>
<p> # print only those lines where field #5 is NOT equal to "abc123"<br />
 # This will also print lines which have less than 5 fields.<br />
 awk '$5 != "abc123"'<br />
 awk '!($5 == "abc123")'</p>
<p> # matching a field against a regular expression<br />
 awk '$7  ~ /^[a-f]/'    # print line if field #7 matches regex<br />
 awk '$7 !~ /^[a-f]/'    # print line if field #7 does NOT match regex</p>
<p> # print the line immediately before a regex, but not the line<br />
 # containing the regex<br />
 awk '/regex/{print x};{x=$0}'<br />
 awk '/regex/{print (NR==1 ? "match on line 1" : x)};{x=$0}'</p>
<p> # print the line immediately after a regex, but not the line<br />
 # containing the regex<br />
 awk '/regex/{getline;print}'</p>
<p> # grep for AAA and BBB and CCC (in any order on the same line)<br />
 awk '/AAA/ &#038;& /BBB/ &#038;& /CCC/'</p>
<p> # grep for AAA and BBB and CCC (in that order)<br />
 awk '/AAA.*BBB.*CCC/'</p>
<p> # print only lines of 65 characters or longer<br />
 awk 'length > 64'</p>
<p> # print only lines of less than 65 characters<br />
 awk 'length < 64'</p>
<p> # print section of file from regular expression to end of file<br />
 awk '/regex/,0'<br />
 awk '/regex/,EOF'</p>
<p> # print section of file based on line numbers (lines 8-12, inclusive)<br />
 awk 'NR==8,NR==12'</p>
<p> # print line number 52<br />
 awk 'NR==52'<br />
 awk 'NR==52 {print;exit}'          # more efficient on large files</p>
<p> # print section of file between two regular expressions (inclusive)<br />
 awk '/Iowa/,/Montana/'             # case sensitive</p>
<p>SELECTIVE DELETION OF CERTAIN LINES:</p>
<p> # delete ALL blank lines from a file (same as "grep '.' ")<br />
 awk NF<br />
 awk '/./'</p>
<p> # remove duplicate, consecutive lines (emulates "uniq")<br />
 awk 'a !~ $0; {a=$0}'</p>
<p> # remove duplicate, nonconsecutive lines<br />
 awk '!a[$0]++'                     # most concise script<br />
 awk '!($0 in a){a[$0];print}'      # most efficient script</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/awk-scripts-and-examples/&amp;t=AWK+Scripts+and+Examples&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=AWK+Scripts+and+Examples;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/awk-scripts-and-examples/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-162-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/awk-scripts-and-examples/&quot;&gt;AWK Scripts and Examples&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/awk-scripts-and-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SED Tutorial and Examples</title>
		<link>http://www.scriptbits.net/2009/07/sed-one-liners/</link>
		<comments>http://www.scriptbits.net/2009/07/sed-one-liners/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 20:21:11 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[file manipulation]]></category>
		<category><![CDATA[find and replace]]></category>
		<category><![CDATA[one line sed examples]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/2009/07/sed-one-liners/</guid>
		<description><![CDATA[Do you do a lot of file/text manipulation?  If so, you probably are familiar with sed.  The following is a list of great sed examples.  The original can be found at:  Soucreforge




I haven't seen any updates to it in a while, or any comments, so I thought I'd repost it here [...]]]></description>
			<content:encoded><![CDATA[<p>Do you do a lot of file/text manipulation?  If so, you probably are familiar with sed.  The following is a list of great sed examples.  The original can be found at:  <a href="http://sed.sourceforge.net/sed1line.txt">Soucreforge</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>I haven't seen any updates to it in a while, or any comments, so I thought I'd repost it here and encourage comments and/or additions to it.  In the next couple of days I'll be adding similar threads specific to  awk and perl.</p>
<p>FILE SPACING:</p>
<p> # double space a file<br />
 sed G</p>
<p> # double space a file which already has blank lines in it. Output file<br />
 # should contain no more than one blank line between lines of text.<br />
 sed '/^$/d;G'</p>
<p> # triple space a file<br />
 sed 'G;G'</p>
<p> # undo double-spacing (assumes even-numbered lines are always blank)<br />
 sed 'n;d'</p>
<p> # insert a blank line above every line which matches "regex"<br />
 sed '/regex/{x;p;x;}'</p>
<p> # insert a blank line below every line which matches "regex"<br />
 sed '/regex/G'</p>
<p> # insert a blank line above and below every line which matches "regex"<br />
 sed '/regex/{x;p;x;G;}'</p>
<p>NUMBERING:</p>
<p> # number each line of a file (simple left alignment). Using a tab (see<br />
 # note on '\t' at end of file) instead of space will preserve margins.<br />
 sed = filename | sed 'N;s/\n/\t/'</p>
<p> # number each line of a file (number on left, right-aligned)<br />
 sed = filename | sed 'N; s/^/     /; s/ *\(.\{6,\}\)\n/\1  /'</p>
<p> # number each line of file, but only print numbers if line is not blank<br />
 sed '/./=' filename | sed '/./N; s/\n/ /'</p>
<p> # count lines (emulates "wc -l")<br />
 sed -n '$='</p>
<p>TEXT CONVERSION AND SUBSTITUTION:</p>
<p> # IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format.<br />
 sed 's/.$//'               # assumes that all lines end with CR/LF<br />
 sed 's/^M$//'              # in bash/tcsh, press Ctrl-V then Ctrl-M<br />
 sed 's/\x0D$//'            # works on ssed, gsed 3.02.80 or higher</p>
<p> # IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format.<br />
 sed "s/$/`echo -e \\\r`/"            # command line under ksh<br />
 sed 's/$'"/`echo \\\r`/"             # command line under bash<br />
 sed "s/$/`echo \\\r`/"               # command line under zsh<br />
 sed 's/$/\r/'                        # gsed 3.02.80 or higher</p>
<p> # IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format.<br />
 sed "s/$//"                          # method 1<br />
 sed -n p                             # method 2</p>
<p> # IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format.<br />
 # Can only be done with UnxUtils sed, version 4.0.7 or higher. The<br />
 # UnxUtils version can be identified by the custom "--text" switch<br />
 # which appears when you use the "--help" switch. Otherwise, changing<br />
 # DOS newlines to Unix newlines cannot be done with sed in a DOS<br />
 # environment. Use "tr" instead.<br />
 sed "s/\r//" infile >outfile         # UnxUtils sed v4.0.7 or higher<br />
 tr -d \r <infile >outfile            # GNU tr version 1.22 or higher</p>
<p> # delete leading whitespace (spaces, tabs) from front of each line<br />
 # aligns all text flush left<br />
 sed 's/^[ \t]*//'                    # see note on '\t' at end of file</p>
<p> # delete trailing whitespace (spaces, tabs) from end of each line<br />
 sed 's/[ \t]*$//'                    # see note on '\t' at end of file</p>
<p> # delete BOTH leading and trailing whitespace from each line<br />
 sed 's/^[ \t]*//;s/[ \t]*$//'</p>
<p> # insert 5 blank spaces at beginning of each line (make page offset)<br />
 sed 's/^/     /'</p>
<p> # align all text flush right on a 79-column width<br />
 sed -e :a -e 's/^.\{1,78\}$/ &#038;/;ta'  # set at 78 plus 1 space</p>
<p> # center all text in the middle of 79-column width. In method 1,<br />
 # spaces at the beginning of the line are significant, and trailing<br />
 # spaces are appended at the end of the line. In method 2, spaces at<br />
 # the beginning of the line are discarded in centering the line, and<br />
 # no trailing spaces appear at the end of lines.<br />
 sed  -e :a -e 's/^.\{1,77\}$/ &#038; /;ta'                     # method 1<br />
 sed  -e :a -e 's/^.\{1,77\}$/ &#038;/;ta' -e 's/\( *\)\1/\1/'  # method 2</p>
<p> # substitute (find and replace) "foo" with "bar" on each line<br />
 sed 's/foo/bar/'             # replaces only 1st instance in a line<br />
 sed 's/foo/bar/4'            # replaces only 4th instance in a line<br />
 sed 's/foo/bar/g'            # replaces ALL instances in a line<br />
 sed 's/\(.*\)foo\(.*foo\)/\1bar\2/' # replace the next-to-last case<br />
 sed 's/\(.*\)foo/\1bar/'            # replace only the last case</p>
<p> # substitute "foo" with "bar" ONLY for lines which contain "baz"<br />
 sed '/baz/s/foo/bar/g'</p>
<p> # substitute "foo" with "bar" EXCEPT for lines which contain "baz"<br />
 sed '/baz/!s/foo/bar/g'</p>
<p> # change "scarlet" or "ruby" or "puce" to "red"<br />
 sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g'   # most seds<br />
 gsed 's/scarlet\|ruby\|puce/red/g'                # GNU sed only</p>
<p> # reverse order of lines (emulates "tac")<br />
 # bug/feature in HHsed v1.5 causes blank lines to be deleted<br />
 sed '1!G;h;$!d'               # method 1<br />
 sed -n '1!G;h;$p'             # method 2</p>
<p> # reverse each character on the line (emulates "rev")<br />
 sed '/\n/!G;s/\(.\)\(.*\n\)/&#038;\2\1/;//D;s/.//'</p>
<p> # join pairs of lines side-by-side (like "paste")<br />
 sed '$!N;s/\n/ /'</p>
<p> # if a line ends with a backslash, append the next line to it<br />
 sed -e :a -e '/\\$/N; s/\\\n//; ta'</p>
<p> # if a line begins with an equal sign, append it to the previous line<br />
 # and replace the "=" with a single space<br />
 sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D'</p>
<p> # add commas to numeric strings, changing "1234567" to "1,234,567"<br />
 gsed ':a;s/\B[0-9]\{3\}\>/,&#038;/;ta'                     # GNU sed<br />
 sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'  # other seds</p>
<p> # add commas to numbers with decimal points and minus signs (GNU sed)<br />
 gsed -r ':a;s/(^|[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g;ta'</p>
<p> # add a blank line every 5 lines (after lines 5, 10, 15, 20, etc.)<br />
 gsed '0~5G'                  # GNU sed only<br />
 sed 'n;n;n;n;G;'             # other seds</p>
<p>SELECTIVE PRINTING OF CERTAIN LINES:</p>
<p> # print first 10 lines of file (emulates behavior of "head")<br />
 sed 10q</p>
<p> # print first line of file (emulates "head -1")<br />
 sed q</p>
<p> # print the last 10 lines of a file (emulates "tail")<br />
 sed -e :a -e '$q;N;11,$D;ba'</p>
<p> # print the last 2 lines of a file (emulates "tail -2")<br />
 sed '$!N;$!D'</p>
<p> # print the last line of a file (emulates "tail -1")<br />
 sed '$!d'                    # method 1<br />
 sed -n '$p'                  # method 2</p>
<p> # print the next-to-the-last line of a file<br />
 sed -e '$!{h;d;}' -e x              # for 1-line files, print blank line<br />
 sed -e '1{$q;}' -e '$!{h;d;}' -e x  # for 1-line files, print the line<br />
 sed -e '1{$d;}' -e '$!{h;d;}' -e x  # for 1-line files, print nothing</p>
<p> # print only lines which match regular expression (emulates "grep")<br />
 sed -n '/regexp/p'           # method 1<br />
 sed '/regexp/!d'             # method 2</p>
<p> # print only lines which do NOT match regexp (emulates "grep -v")<br />
 sed -n '/regexp/!p'          # method 1, corresponds to above<br />
 sed '/regexp/d'              # method 2, simpler syntax</p>
<p> # print the line immediately before a regexp, but not the line<br />
 # containing the regexp<br />
 sed -n '/regexp/{g;1!p;};h'</p>
<p> # print the line immediately after a regexp, but not the line<br />
 # containing the regexp<br />
 sed -n '/regexp/{n;p;}'</p>
<p> # print 1 line of context before and after regexp, with line number<br />
 # indicating where the regexp occurred (similar to "grep -A1 -B1")<br />
 sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h</p>
<p> # grep for AAA and BBB and CCC (in any order)<br />
 sed '/AAA/!d; /BBB/!d; /CCC/!d'</p>
<p> # grep for AAA and BBB and CCC (in that order)<br />
 sed '/AAA.*BBB.*CCC/!d'</p>
<p> # grep for AAA or BBB or CCC (emulates "egrep")<br />
 sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d    # most seds<br />
 gsed '/AAA\|BBB\|CCC/!d'                        # GNU sed only</p>
<p> # print paragraph if it contains AAA (blank lines separate paragraphs)<br />
 # HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below<br />
 sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'</p>
<p> # print paragraph if it contains AAA and BBB and CCC (in any order)<br />
 sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'</p>
<p> # print paragraph if it contains AAA or BBB or CCC<br />
 sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d<br />
 gsed '/./{H;$!d;};x;/AAA\|BBB\|CCC/b;d'         # GNU sed only</p>
<p> # print only lines of 65 characters or longer<br />
 sed -n '/^.\{65\}/p'</p>
<p> # print only lines of less than 65 characters<br />
 sed -n '/^.\{65\}/!p'        # method 1, corresponds to above<br />
 sed '/^.\{65\}/d'            # method 2, simpler syntax</p>
<p> # print section of file from regular expression to end of file<br />
 sed -n '/regexp/,$p'</p>
<p> # print section of file based on line numbers (lines 8-12, inclusive)<br />
 sed -n '8,12p'               # method 1<br />
 sed '8,12!d'                 # method 2</p>
<p> # print line number 52<br />
 sed -n '52p'                 # method 1<br />
 sed '52!d'                   # method 2<br />
 sed '52q;d'                  # method 3, efficient on large files</p>
<p> # beginning at line 3, print every 7th line<br />
 gsed -n '3~7p'               # GNU sed only<br />
 sed -n '3,${p;n;n;n;n;n;n;}' # other seds</p>
<p> # print section of file between two regular expressions (inclusive)<br />
 sed -n '/Iowa/,/Montana/p'             # case sensitive</p>
<p>SELECTIVE DELETION OF CERTAIN LINES:</p>
<p> # print all of file EXCEPT section between 2 regular expressions<br />
 sed '/Iowa/,/Montana/d'</p>
<p> # delete duplicate, consecutive lines from a file (emulates "uniq").<br />
 # First line in a set of duplicate lines is kept, rest are deleted.<br />
 sed '$!N; /^\(.*\)\n\1$/!P; D'</p>
<p> # delete duplicate, nonconsecutive lines from a file. Beware not to<br />
 # overflow the buffer size of the hold space, or else use GNU sed.<br />
 sed -n 'G; s/\n/&#038;&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P'</p>
<p> # delete all lines except duplicate lines (emulates "uniq -d").<br />
 sed '$!N; s/^\(.*\)\n\1$/\1/; t; D'</p>
<p> # delete the first 10 lines of a file<br />
 sed '1,10d'</p>
<p> # delete the last line of a file<br />
 sed '$d'</p>
<p> # delete the last 2 lines of a file<br />
 sed 'N;$!P;$!D;$d'</p>
<p> # delete the last 10 lines of a file<br />
 sed -e :a -e '$d;N;2,10ba' -e 'P;D'   # method 1<br />
 sed -n -e :a -e '1,10!{P;N;D;};N;ba'  # method 2</p>
<p> # delete every 8th line<br />
 gsed '0~8d'                           # GNU sed only<br />
 sed 'n;n;n;n;n;n;n;d;'                # other seds</p>
<p> # delete lines matching pattern<br />
 sed '/pattern/d'</p>
<p> # delete ALL blank lines from a file (same as "grep '.' ")<br />
 sed '/^$/d'                           # method 1<br />
 sed '/./!d'                           # method 2</p>
<p> # delete all CONSECUTIVE blank lines from file except the first; also<br />
 # deletes all blank lines from top and end of file (emulates "cat -s")<br />
 sed '/./,/^$/!d'          # method 1, allows 0 blanks at top, 1 at EOF<br />
 sed '/^$/N;/\n$/D'        # method 2, allows 1 blank at top, 0 at EOF</p>
<p> # delete all CONSECUTIVE blank lines from file except the first 2:<br />
 sed '/^$/N;/\n$/N;//D'</p>
<p> # delete all leading blank lines at top of file<br />
 sed '/./,$!d'</p>
<p> # delete all trailing blank lines at end of file<br />
 sed -e :a -e '/^\n*$/{$d;N;ba' -e '}'  # works on all seds<br />
 sed -e :a -e '/^\n*$/N;/\n$/ba'        # ditto, except for gsed 3.02.*</p>
<p> # delete the last line of each paragraph<br />
 sed -n '/^$/{p;h;};/./{x;/./p;}'</p>
<p>SPECIAL APPLICATIONS:</p>
<p> # remove nroff overstrikes (char, backspace) from man pages. The 'echo'<br />
 # command may need an -e switch if you use Unix System V or bash shell.<br />
 sed "s/.`echo \\\b`//g"    # double quotes required for Unix environment<br />
 sed 's/.^H//g'             # in bash/tcsh, press Ctrl-V and then Ctrl-H<br />
 sed 's/.\x08//g'           # hex expression for sed 1.5, GNU sed, ssed</p>
<p> # get Usenet/e-mail message header<br />
 sed '/^$/q'                # deletes everything after first blank line</p>
<p> # get Usenet/e-mail message body<br />
 sed '1,/^$/d'              # deletes everything up to first blank line</p>
<p> # get Subject header, but remove initial "Subject: " portion<br />
 sed '/^Subject: */!d; s///;q'</p>
<p> # get return address header<br />
 sed '/^Reply-To:/q; /^From:/h; /./d;g;q'</p>
<p> # parse out the address proper. Pulls out the e-mail address by itself<br />
 # from the 1-line return address header (see preceding script)<br />
 sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//'</p>
<p> # add a leading angle bracket and space to each line (quote a message)<br />
 sed 's/^/> /'</p>
<p> # delete leading angle bracket &#038; space from each line (unquote a message)<br />
 sed 's/^> //'</p>
<p> # remove most HTML tags (accommodates multiple-line tags)<br />
 sed -e :a -e 's/<[^>]*>//g;/</N;//ba'</p>
<p> # extract multi-part uuencoded binaries, removing extraneous header<br />
 # info, so that only the uuencoded portion remains. Files passed to<br />
 # sed must be passed in the proper order. Version 1 can be entered<br />
 # from the command line; version 2 can be made into an executable<br />
 # Unix shell script. (Modified from a script by Rahul Dhesi.)<br />
 sed '/^end/,/^begin/d' file1 file2 ... fileX | uudecode   # vers. 1<br />
 sed '/^end/,/^begin/d' "$@" | uudecode                    # vers. 2</p>
<p> # sort paragraphs of file alphabetically. Paragraphs are separated by blank<br />
 # lines. GNU sed uses \v for vertical tab, or any unique char will do.<br />
 sed '/./{H;d;};x;s/\n/={NL}=/g' file | sort | sed '1s/={NL}=//;s/={NL}=/\n/g'<br />
 gsed '/./{H;d};x;y/\n/\v/' file | sort | sed '1s/\v//;y/\v/\n/'</p>
<p> # zip up each .TXT file individually, deleting the source file and<br />
 # setting the name of each .ZIP file to the basename of the .TXT file<br />
 # (under DOS: the "dir /b" switch returns bare filenames in all caps).<br />
 echo @echo off >zipup.bat<br />
 dir /b *.txt | sed "s/^\(.*\)\.TXT/pkzip -mo \1 \1.TXT/" >>zipup.bat</p>
<p>TYPICAL USE: Sed takes one or more editing commands and applies all of<br />
them, in sequence, to each line of input. After all the commands have<br />
been applied to the first input line, that line is output and a second<br />
input line is taken for processing, and the cycle repeats. The<br />
preceding examples assume that input comes from the standard input<br />
device (i.e, the console, normally this will be piped input). One or<br />
more filenames can be appended to the command line if the input does<br />
not come from stdin. Output is sent to stdout (the screen). Thus:</p>
<p> cat filename | sed '10q'        # uses piped input<br />
 sed '10q' filename              # same effect, avoids a useless "cat"<br />
 sed '10q' filename > newfile    # redirects output to disk</p>
<p>For additional syntax instructions, including the way to apply editing<br />
commands from a disk file instead of the command line, consult "sed &#038;<br />
awk, 2nd Edition," by Dale Dougherty and Arnold Robbins (O'Reilly,<br />
1997; http://www.ora.com), "UNIX Text Processing," by Dale Dougherty<br />
and Tim O'Reilly (Hayden Books, 1987) or the tutorials by Mike Arst<br />
distributed in U-SEDIT2.ZIP (many sites). To fully exploit the power<br />
of sed, one must understand "regular expressions." For this, see<br />
"Mastering Regular Expressions" by Jeffrey Friedl (O'Reilly, 1997).<br />
The manual ("man") pages on Unix systems may be helpful (try "man<br />
sed", "man regexp", or the subsection on regular expressions in "man<br />
ed"), but man pages are notoriously difficult. They are not written to<br />
teach sed use or regexps to first-time users, but as a reference text<br />
for those already acquainted with these tools.</p>
<p>QUOTING SYNTAX: The preceding examples use single quotes ('...')<br />
instead of double quotes ("...") to enclose editing commands, since<br />
sed is typically used on a Unix platform. Single quotes prevent the<br />
Unix shell from intrepreting the dollar sign ($) and backquotes<br />
(`...`), which are expanded by the shell if they are enclosed in<br />
double quotes. Users of the "csh" shell and derivatives will also need<br />
to quote the exclamation mark (!) with the backslash (i.e., \!) to<br />
properly run the examples listed above, even within single quotes.<br />
Versions of sed written for DOS invariably require double quotes<br />
("...") instead of single quotes to enclose editing commands.</p>
<p>USE OF '\t' IN SED SCRIPTS: For clarity in documentation, we have used<br />
the expression '\t' to indicate a tab character (0x09) in the scripts.<br />
However, most versions of sed do not recognize the '\t' abbreviation,<br />
so when typing these scripts from the command line, you should press<br />
the TAB key instead. '\t' is supported as a regular expression<br />
metacharacter in awk, perl, and HHsed, sedmod, and GNU sed v3.02.80.</p>
<p>VERSIONS OF SED: Versions of sed do differ, and some slight syntax<br />
variation is to be expected. In particular, most do not support the<br />
use of labels (:name) or branch instructions (b,t) within editing<br />
commands, except at the end of those commands. We have used the syntax<br />
which will be portable to most users of sed, even though the popular<br />
GNU versions of sed allow a more succinct syntax. When the reader sees<br />
a fairly long command such as this:</p>
<p>   sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d</p>
<p>it is heartening to know that GNU sed will let you reduce it to:</p>
<p>   sed '/AAA/b;/BBB/b;/CCC/b;d'      # or even<br />
   sed '/AAA\|BBB\|CCC/b;d'</p>
<p>In addition, remember that while many versions of sed accept a command<br />
like "/one/ s/RE1/RE2/", some do NOT allow "/one/! s/RE1/RE2/", which<br />
contains space before the 's'. Omit the space when typing the command.</p>
<p>OPTIMIZING FOR SPEED: If execution speed needs to be increased (due to<br />
large input files or slow processors or hard disks), substitution will<br />
be executed more quickly if the "find" expression is specified before<br />
giving the "s/.../.../" instruction. Thus:</p>
<p>   sed 's/foo/bar/g' filename         # standard replace command<br />
   sed '/foo/ s/foo/bar/g' filename   # executes more quickly<br />
   sed '/foo/ s//bar/g' filename      # shorthand sed syntax</p>
<p>On line selection or deletion in which you only need to output lines<br />
from the first part of the file, a "quit" command (q) in the script<br />
will drastically reduce processing time for large files. Thus:</p>
<p>   sed -n '45,50p' filename           # print line nos. 45-50 of a file<br />
   sed -n '51q;45,50p' filename       # same, but executes much faster</p>
<p>If you have any additional scripts to contribute or if you find errors<br />
in this document, please send e-mail to the compiler. Indicate the<br />
version of sed you used, the operating system it was compiled for, and<br />
the nature of the problem. To qualify as a one-liner, the command line<br />
must be 65 characters or less. Various scripts in this file have been<br />
written or contributed by:</p>
<p> Al Aab                   # founder of "seders" list<br />
 Edgar Allen              # various<br />
 Yiorgos Adamopoulos      # various<br />
 Dale Dougherty           # author of "sed &#038; awk"<br />
 Carlos Duarte            # author of "do it with sed"<br />
 Eric Pement              # author of this document<br />
 Ken Pizzini              # author of GNU sed v3.02<br />
 S.G. Ravenhall           # great de-html script<br />
 Greg Ubben               # many contributions &#038; much help</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/sed-one-liners/&amp;t=SED+Tutorial+and+Examples&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=SED+Tutorial+and+Examples;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/sed-one-liners/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-153-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/sed-one-liners/&quot;&gt;SED Tutorial and Examples&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/sed-one-liners/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Review: ReadyNAS 1100 NAS appliance</title>
		<link>http://www.scriptbits.net/2009/07/review-readynas-1100-nas-appliance/</link>
		<comments>http://www.scriptbits.net/2009/07/review-readynas-1100-nas-appliance/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 14:35:17 +0000</pubDate>
		<dc:creator>ddctomc</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[ReadyNAS]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Storage]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/?p=66</guid>
		<description><![CDATA[ 



As an alternative to hanging USB drives off some of our production servers we decided to purchase 2 ReadyNAS 1100 NAS appliances. Our primary goal for these where to use them for low access archival storage of large amounts of data. We purchased 2 of these to act as a primary and secondary with [...]]]></description>
			<content:encoded><![CDATA[<p> <script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* tom460 */
google_ad_slot = "2841714296";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>As an alternative to hanging USB drives off some of our production servers we decided to purchase 2 <a title="ReadyNAS 1100" href="http://www.google.com/products?q=readynas+1100&amp;hl=en&amp;aq=f">ReadyNAS 1100</a> NAS appliances. Our primary goal for these where to use them for low access archival storage of large amounts of data. We purchased 2 of these to act as a primary and secondary with the secondary doing a nightly NFS based backup from the primary (More on this later). We bought the 1TB (4x250GB) version and replaced the drives in each appliance with <a href="http://www.google.com/products?q=seagate+1.5TB&amp;hl=en">Seagate 1.5TB</a> drives. This swap was pain free and the rebuild time of the array was ~6 hours each. Total cost per appliance including new drives was ~$2,000.</p>
<p><strong>Setup and configure:</strong></p>
<p>Install was very simple. We decided on using the default RAID-X array configuration. We tested using the RAID5 (Which uses Linux's MD based software RAID) but found that RAID-X provides better performance for small files (Our use case). Total usable space was a little over 4TB.</p>
<p>Configuration of the Network and system was straight forward and what you'd expect from a NAS aimed at the SOHO market. The GUI was simple to follow and laid out logically. Getting it on the network and sharing out files took literally a few minutes. Since we are mostly a Linux/Solaris shop we were only focused on NFS exports. With these we found the performance fairly limited unless the NFS export was set to be async, with Writes going from (sync) ~4MBs to (async) ~20MBs. Setting up the backups between primary and secondary was also done through the GUI. It provides several different ways of pushing/pulling backups from different sources using Rsync, NFS Mount, SMB/CIF Mounts, etc. We choose doing a NFS based pull from the secondary server of the data on the primary. We found this to be the best balance of performance and ease of maintenance. One issue we found was that when backing up volumes with large number of files (Ie 10's of millions) the backup log file will fill the 2GB flash root volume. We had to modify the default netgear backup script to relocate this to the RAID volume instead. Another issue is that its using cp and not something like rsync. This means that it will add new files but not remove deleted files on the destination. The solution to this is to make the script use rsync instead of cp, but we have not attempted this yet. </p>
<p>One of the selling points of these devices was the strong support for customization with adding SSH and APT support to the device fully supported by the vendor. Adding these to the device was just a matter of downloading the <a href='http://www.readynas.com/?cat=41'>plugins</a> and installing them through the GUI. Once they were installed we could then add things like development tools and other useful command line utilities such as systat, iozone and bacula-sd. Another benefit of gaining command line access was that we were able to find root causes of performance bottle necks in the different methods of accessing the device (Ie we found that the main bottle neck is CPU, and the best method was NFS over SMB and Rsync because of this). </p>
<p><strong>Performance:</strong><br />
We ran an <a href='http://www.iozone.org'>iozone</a> test directly on the device:</p>
<pre>
        Iozone: Performance Test of File I/O
                Version $Revision: 3.300 $
                Compiled for 32 bit mode.
                Build: linux 

        Contributors:William Norcott, Don Capps, Isom Crawford, Kirby Collins
                     Al Slater, Scott Rhine, Mike Wisner, Ken Goss
                     Steve Landherr, Brad Smith, Mark Kelly, Dr. Alain CYR,
                     Randy Dunlap, Mark Montague, Dan Million,
                     Jean-Marc Zucconi, Jeff Blomberg, Benny Halevy,
                     Erik Habbinga, Kris Strecker, Walter Wong, Joshua Root.

        Run began: Fri May 15 01:57:14 2009

        OPS Mode. Output is in operations per second.
        Record Size 1 KB
        File size set to 1048576 KB
        Excel chart generation enabled
        Command line used: iozone -i 0 -i 1 -O -r 1k -s 1G -t 1 -R
        Time Resolution = 0.000001 seconds.
        Processor cache size set to 1024 Kbytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
        Throughput test with 1 process
        Each process writes a 1048576 Kbyte file in 1 Kbyte records

        Children see throughput for  1 initial writers  =    9845.89 ops/sec
        Parent sees throughput for  1 initial writers   =    9734.81 ops/sec
        Min throughput per process                      =    9845.89 ops/sec
        Max throughput per process                      =    9845.89 ops/sec
        Avg throughput per process                      =    9845.89 ops/sec
        Min xfer                                        = 1048576.00 ops

        Children see throughput for  1 rewriters        =    5629.51 ops/sec
        Parent sees throughput for  1 rewriters         =    5599.09 ops/sec
        Min throughput per process                      =    5629.51 ops/sec
        Max throughput per process                      =    5629.51 ops/sec
        Avg throughput per process                      =    5629.51 ops/sec
        Min xfer                                        = 1048576.00 ops

        Children see throughput for  1 readers          =   24118.04 ops/sec
        Parent sees throughput for  1 readers           =   24116.90 ops/sec
        Min throughput per process                      =   24118.04 ops/sec
        Max throughput per process                      =   24118.04 ops/sec
        Avg throughput per process                      =   24118.04 ops/sec
        Min xfer                                        = 1048576.00 ops

        Children see throughput for 1 re-readers        =   26780.61 ops/sec
        Parent sees throughput for 1 re-readers         =   26778.54 ops/sec
        Min throughput per process                      =   26780.61 ops/sec
        Max throughput per process                      =   26780.61 ops/sec
        Avg throughput per process                      =   26780.61 ops/sec
        Min xfer                                        = 1048576.00 ops
</pre>
<p><strong>Conclusion:</strong><br />
These devices for the money provide a very flexible platform for putting a fair amount of data onto the network. Their main short coming is the limited CPU resources which cause a bottle neck on the performance you can expect from them.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/review-readynas-1100-nas-appliance/&amp;t=Review%3A+ReadyNAS+1100+NAS+appliance&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Review%3A+ReadyNAS+1100+NAS+appliance;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/review-readynas-1100-nas-appliance/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-66-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/review-readynas-1100-nas-appliance/&quot;&gt;Review: ReadyNAS 1100 NAS appliance&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/review-readynas-1100-nas-appliance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Pager</title>
		<link>http://www.scriptbits.net/2009/07/mysql-pager/</link>
		<comments>http://www.scriptbits.net/2009/07/mysql-pager/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 14:14:55 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysql pager]]></category>
		<category><![CDATA[mysql tips]]></category>
		<category><![CDATA[mysql tricks]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/2009/07/mysql-pager/</guid>
		<description><![CDATA[The pager command in mysql is pretty cool.  When you use it, anything you type on the mysql command line is piped thru what you set it to.  Here's one I use often, especially when load is high and/or replication starts to get behind.  

mysql> pager grep -v "Sleep" &#124;sort -n -t [...]]]></description>
			<content:encoded><![CDATA[<p>The pager command in mysql is pretty cool.  When you use it, anything you type on the mysql command line is piped thru what you set it to.  Here's one I use often, especially when load is high and/or replication starts to get behind.  </p>
<pre>
mysql> pager grep -v "Sleep" |sort -n -t "|" -k 7 |tail -5
PAGER set to 'grep -v "Sleep" |sort -n -t "|" -k 7 |tail -5'
mysql> show processlist;
</pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Now the process list is stripped of any sleeping processes and shows the 5 oldest ones.</p>
<p>You could also use pager to pipe your output thru a script.  Leave a comment if you have a useful one.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/mysql-pager/&amp;t=MySQL+Pager&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=MySQL+Pager;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/mysql-pager/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-142-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/mysql-pager/&quot;&gt;MySQL Pager&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/mysql-pager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Swap File</title>
		<link>http://www.scriptbits.net/2009/07/make-swap-file/</link>
		<comments>http://www.scriptbits.net/2009/07/make-swap-file/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 12:51:47 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[mkswp]]></category>
		<category><![CDATA[swap]]></category>
		<category><![CDATA[swapfile]]></category>
		<category><![CDATA[swapon]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/2009/07/make-swap-file/</guid>
		<description><![CDATA[So you kinda screwed up when you did your partitions and now need more swap.  Here's a quick and easy way to use a swap file, which should perform almost as well as a swap partition.
1.  Make a big ol' 2G file

dd if=/dev/zero of=/myswapfile bs=2097152 count=1000





2.  Tell that file it's a swapfile

mkswp [...]]]></description>
			<content:encoded><![CDATA[<p>So you kinda screwed up when you did your partitions and now need more swap.  Here's a quick and easy way to use a swap file, which should perform almost as well as a swap partition.</p>
<p>1.  Make a big ol' 2G file</p>
<pre>
dd if=/dev/zero of=/myswapfile bs=2097152 count=1000
</pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>2.  Tell that file it's a swapfile</p>
<pre>
mkswp /myswapfile
</pre>
<p>3.  Activate it</p>
<pre>
swapon /myswapfile
</pre>
<p>4.  Check your work</p>
<pre>
swapon -s
</pre>
<p>You should see your myswapfile in there.  Want it to be a permanent solution instead of a quick fix?  Add this to /etc/fstab</p>
<pre>
/myswapfile swap swap defaults 0 0
</pre>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/make-swap-file/&amp;t=Make+Swap+File&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Make+Swap+File;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/make-swap-file/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-135-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/make-swap-file/&quot;&gt;Make Swap File&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/make-swap-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to identify what processes are generating IO Wait load.</title>
		<link>http://www.scriptbits.net/2009/07/how-to-identify-what-processes-are-generating-io-wait-load/</link>
		<comments>http://www.scriptbits.net/2009/07/how-to-identify-what-processes-are-generating-io-wait-load/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 15:02:48 +0000</pubDate>
		<dc:creator>ddctomc</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Load]]></category>
		<category><![CDATA[processes]]></category>
		<category><![CDATA[Wait]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/2009/07/how-to-identify-what-processes-are-generating-io-wait-load/</guid>
		<description><![CDATA[ 



An easy way to identify what process is generating your IO Wait load is to enable block I/O debugging. This is done by setting /proc/sys/vm/block_dump to a non zero value like:

echo 1 &#62; /proc/sys/vm/block_dump

This will cause messages like the following to start appearing in dmesg:

bash(6856): dirtied inode 19446664 (ld-2.5.so) on md1

Using the following one-liner [...]]]></description>
			<content:encoded><![CDATA[<p> <script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* tom460 */
google_ad_slot = "2841714296";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>An easy way to identify what process is generating your IO Wait load is to enable block I/O debugging. This is done by setting /proc/sys/vm/block_dump to a non zero value like:</p>
<pre>
echo 1 &gt; /proc/sys/vm/block_dump
</pre>
<p>This will cause messages like the following to start appearing in dmesg:</p>
<pre>
bash(6856): dirtied inode 19446664 (ld-2.5.so) on md1
</pre>
<p>Using the following one-liner will produce a summary output of the dmesg entries:</p>
<pre>
dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head
    354 md
    324 export
    288 kjournald
     53 irqbalance
     45 pdflush
     14 portmap
     14 bash
     10 egrep
     10 crond
      8 ncftpput
</pre>
<p>Once you are finished you should disable block I/O debugging by setting /proc/sys/vm/block_dump to a zero value like:</p>
<pre>
echo 0 &gt; /proc/sys/vm/block_dump
</pre>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/how-to-identify-what-processes-are-generating-io-wait-load/&amp;t=How+to+identify+what+processes+are+generating+IO+Wait+load.&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=How+to+identify+what+processes+are+generating+IO+Wait+load.;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/how-to-identify-what-processes-are-generating-io-wait-load/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-122-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/how-to-identify-what-processes-are-generating-io-wait-load/&quot;&gt;How to identify what processes are generating IO Wait load.&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/how-to-identify-what-processes-are-generating-io-wait-load/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create Automated LVM Snapshots for MySQL Backup</title>
		<link>http://www.scriptbits.net/2009/07/create-automated-lvm-snapshots-for-mysql-backup/</link>
		<comments>http://www.scriptbits.net/2009/07/create-automated-lvm-snapshots-for-mysql-backup/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 13:29:51 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Shell Scripts]]></category>
		<category><![CDATA[mysql backup]]></category>
		<category><![CDATA[mysql disaster recovery]]></category>
		<category><![CDATA[mysql lvm snapshot]]></category>
		<category><![CDATA[mysql snapshot]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/2009/07/create-automated-lvm-snapshots-for-mysql-backup/</guid>
		<description><![CDATA[I won't go thru how to set up LVM, or even really how to do run a snapshot.  If you're interested in scripting your snapshots for backup purporses, it is assumed you already have LVM set up correctly, and can take a snapshot.  So...let's get right to the ScriptBit and automate this thing....
The [...]]]></description>
			<content:encoded><![CDATA[<p>I won't go thru how to set up LVM, or even really how to do run a snapshot.  If you're interested in scripting your snapshots for backup purporses, it is assumed you already have LVM set up correctly, and can take a snapshot.  So...let's get right to the ScriptBit and automate this thing....</p>
<p>The following script requires 20G free for a snapshot.  If you don't need/have that much, simply change the @20G to whatever fits your needs.  It also assumes you are running mysql.  If you aren't, comment that stuff out to.  If you are, please note that the tables are LOCKED.  My 150G db takes about 30 seconds to snap after the lock is required.  If you cannot live with that, please don't run it.  So far I've yet to see a snapshot without locking the tables be of any use.  Lastly, it appends the slave status to a file so you may use it to restore a slave.  Here it is:</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Name this /root/crons/mysnap_lvm</p>
<pre>
#!/usr/bin/perl

use DBIx::DWIW;

my $db_user = 'dbuser';
my $db_pass = 'dbpassword';
my $db_host = 'localhost';
my $db_name = 'mysql';
my $conn =  DBIx::DWIW->Connect(DB=>$db_name, User=>$db_user, Pass=>$db_pass, Host=>$db_host);
my $lvmbinpath = '/usr/sbin';
my $masterstatus = '';

printf "%-12s %s \n", "removing", scalar localtime time;
`$lvmbinpath/lvremove -f /dev/VolGroup00/dbbackup.1`;

printf "%-12s %s \n", "stopping slave", scalar localtime time;
system ("mysql -uroot -p$db_pass -e 'slave stop'");
sleep 10;

printf "%-12s %s \n", "flushing", scalar localtime time;
$conn->Execute("FLUSH TABLES");
$conn->Execute("FLUSH TABLES WITH READ LOCK");
$conn->Execute("FLUSH LOGS");

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

printf "%-12s %s \n", "snapping", scalar localtime time;

#   2. From another shell, create snapshot.
`$lvmbinpath/lvcreate -L20G -s -n dbbackup.1 /dev/VolGroup00/LogVol00`;

system ("mysql -uroot -p$db_pass -e 'show slave status\\G' >> master.status.latest");
system ("mysql -uroot -p$db_pass -e 'show master status\\G' >> master.status.latest");

printf "%-12s %s \n", "Master Status", scalar localtime time;
system ("tail -n 34 master.status.latest");

printf "%-12s %s \n", "unlocking", scalar localtime time;

#   3. From the first client, execute UNLOCK TABLES.
$conn->Execute("UNLOCK TABLES");
system ("mysql -uroot -p$db_pass -e 'slave start'");

#   4. Show current snaphots

printf "%-12s %s \n", "LVM Status", scalar localtime time;
system ("$lvmbinpath/lvscan");

printf "%-12s %s \n", "done", scalar localtime time;
$conn->Disconnect;
</pre>
<p>Now, lets be really cool and use a little wrapper to cron this job, email us the results, and log it.</p>
<p>Call this guy /root/crons/mycronwrapper.sh</p>
<pre>
#!/bin/bash

# wrapper to launch mysql backup job and report status.
to="someguy@somewhere.com"
dir="/root/crons"
cmd="/root/crons/mysnap_lvm"
status="FAILURE"
subject="`hostname -s` Hour:`date +%H` MySQL Snapshot"
log="$dir/mysqlsnapshot-`date +%Y%m%d%H`.log"
cd $dir

# do command
echo $cmd > $log
$cmd >> $log
cmdrtn=$?

# check log
grep -vq inactive $log
logrtn=$?

if [ "$cmdrtn" -eq "0" ] &#038;& [ "$logrtn" -eq "0" ]; then
  status="SUCCESS"
fi

cat $log |mail -s "$subject $status" $to
</pre>
<p>Cron it and you're all set:</p>
<pre>
cd /etc/cron.daily
ln -s /root/crons/mycronwrapper.sh mycronwrapper
</pre>
<p>You're done!</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/create-automated-lvm-snapshots-for-mysql-backup/&amp;t=Create+Automated+LVM+Snapshots+for+MySQL+Backup&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Create+Automated+LVM+Snapshots+for+MySQL+Backup;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/create-automated-lvm-snapshots-for-mysql-backup/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-103-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/create-automated-lvm-snapshots-for-mysql-backup/&quot;&gt;Create Automated LVM Snapshots for MySQL Backup&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/create-automated-lvm-snapshots-for-mysql-backup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add a 301 redirect, the SEO friendly way to go.</title>
		<link>http://www.scriptbits.net/2009/07/add-a-301-redirect-the-seo-friendly-way-to-go/</link>
		<comments>http://www.scriptbits.net/2009/07/add-a-301-redirect-the-seo-friendly-way-to-go/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 18:28:40 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[301 redirect]]></category>
		<category><![CDATA[apache redirect]]></category>
		<category><![CDATA[canonical url]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/2009/07/add-a-301-redirect-the-seo-friendly-way-to-go/</guid>
		<description><![CDATA[If you're reading this then you're well aware of WHY you need a 301 redirect for your canonical-url's, so there's no reason to get into duplicate content and how/why Google does things.**   You're here for the ScriptBit.  So, how do you set up your .htaccess file?  The answer is "incredilby easily". [...]]]></description>
			<content:encoded><![CDATA[<p>If you're reading this then you're well aware of WHY you need a 301 redirect for your canonical-url's, so there's no reason to get into duplicate content and how/why Google does things.**   You're here for the ScriptBit.  So, how do you set up your .htaccess file?  The answer is "incredilby easily".  We'll use this site as an example.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Put the following into the .htaccess file (note the dot at the beginning) of your DocRoot:</p>
<pre>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^scriptbits.net [NC]
RewriteRule ^(.*)$ http://www.scriptbits.net/$1 [L,R=301]
</pre>
<p>That's it.  Simple, huh?</p>
<p>**Because they can</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/add-a-301-redirect-the-seo-friendly-way-to-go/&amp;t=Add+a+301+redirect%2C+the+SEO+friendly+way+to+go.&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Add+a+301+redirect%2C+the+SEO+friendly+way+to+go.;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/add-a-301-redirect-the-seo-friendly-way-to-go/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-84-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/add-a-301-redirect-the-seo-friendly-way-to-go/&quot;&gt;Add a 301 redirect, the SEO friendly way to go.&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/add-a-301-redirect-the-seo-friendly-way-to-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup Bonded Interfaces On Linux</title>
		<link>http://www.scriptbits.net/2009/07/setup-bonded-interfaces-on-linux/</link>
		<comments>http://www.scriptbits.net/2009/07/setup-bonded-interfaces-on-linux/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 12:15:17 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bond]]></category>
		<category><![CDATA[bond nics]]></category>
		<category><![CDATA[bonding]]></category>
		<category><![CDATA[interface failover]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/?p=44</guid>
		<description><![CDATA[Here's a real quick and easy process to set up network interface bonding on your Fedora, CentOS or Redhat box.  It assumes that your kernel already supports bonding and that your distro supports master/slave notation in the network interface configs.  Recompiling the kernel and/or installing ifenslave is beyond the scope of this article




Create bond0

cat /etc/sysconfing/network-scripts/ifcfg-bond0

DEVICE=bond0
IPADDR=192.168.1.1
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
Make [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a real quick and easy process to set up network interface bonding on your Fedora, CentOS or Redhat box.  It assumes that your kernel already supports bonding and that your distro supports master/slave notation in the network interface configs.  Recompiling the kernel and/or installing ifenslave is beyond the scope of this article<br />
<script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Create bond0</p>
<pre style="text-align: left; padding-left: 30px;">
cat /etc/sysconfing/network-scripts/ifcfg-bond0

DEVICE=bond0
IPADDR=192.168.1.1
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no</pre>
<p>Make eth0 and eth1 slaves of bond0</p>
<pre style="padding-left: 30px;">cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=no</pre>
<p>Edit modprobe.conf</p>
<pre style="padding-left: 30px;">cat /etc/modprobe.conf

# bonding commands
alias bond0 bonding
options bond0 mode=1 miimon=100
</pre>
<p>In the above, mode=1 is for failover and miimon=100 is to monitor link every 100 ms.  You can use mode=0 for round-robin, miimon=100 should probably stay just like that.</p>
<p>Load bonding driver and restart network, or reboot your computer.</p>
<pre style="padding-left: 30px;">$ modprobe bonding; service network restart</pre>
<p style="padding-left: 30px;">or</p>
<pre style="padding-left: 30px;">$ reboot now</pre>
<p>You now have bonding configured!</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/setup-bonded-interfaces-on-linux/&amp;t=Setup+Bonded+Interfaces+On+Linux&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Setup+Bonded+Interfaces+On+Linux;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/setup-bonded-interfaces-on-linux/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-44-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/setup-bonded-interfaces-on-linux/&quot;&gt;Setup Bonded Interfaces On Linux&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/setup-bonded-interfaces-on-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Show 10 Biggest Directories On Filesystem</title>
		<link>http://www.scriptbits.net/2009/07/show-10-biggest-directories-on-filesystem/</link>
		<comments>http://www.scriptbits.net/2009/07/show-10-biggest-directories-on-filesystem/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 14:26:21 +0000</pubDate>
		<dc:creator>Patrick Kennedy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[big directories]]></category>
		<category><![CDATA[du]]></category>
		<category><![CDATA[show large directories]]></category>

		<guid isPermaLink="false">http://www.scriptbits.net/?p=33</guid>
		<description><![CDATA[Need to find you 10 biggest directories real fast? If you run this from /, it could take a while...but might be worh the wait if you're trying to quickly find where you have large chunks of data.
du -xk &#124; sort -n &#124; tail -20




   tweetmeme_url='http://www.scriptbits.net/2009/07/show-10-biggest-directories-on-filesystem/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; Link to [...]]]></description>
			<content:encoded><![CDATA[<p>Need to find you 10 biggest directories real fast? If you run this from /, it could take a while...but might be worh the wait if you're trying to quickly find where you have large chunks of data.</p>
<p><em><strong>du -xk | sort -n | tail -20</strong></em></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8145719856216687";
/* pk460 */
google_ad_slot = "2193870018";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.scriptbits.net/2009/07/show-10-biggest-directories-on-filesystem/&amp;t=Show+10+Biggest+Directories+On+Filesystem&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Show+10+Biggest+Directories+On+Filesystem;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.scriptbits.net/2009/07/show-10-biggest-directories-on-filesystem/'; tweetmeme_style = 'normal';tweetmeme_source = 'ScriptBits'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div class="su-linkbox" id="post-33-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.scriptbits.net/2009/07/show-10-biggest-directories-on-filesystem/&quot;&gt;Show 10 Biggest Directories On Filesystem&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.scriptbits.net/2009/07/show-10-biggest-directories-on-filesystem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
