<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3602443957408805914</id><updated>2011-04-21T23:06:43.718-04:00</updated><title type='text'>Unix Tips and Tricks</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tributetogrr.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tributetogrr.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>David</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3602443957408805914.post-4892209953986631884</id><published>2008-05-05T16:49:00.002-04:00</published><updated>2008-05-05T17:25:06.301-04:00</updated><title type='text'>Inline Search and Replacement One Liners</title><content type='html'>Here are two ways to do inline file replacement of patterns using perl and sed. Both examples will do a global replacement of the string &lt;span style="font-style: italic;"&gt;orig&lt;/span&gt; with the string &lt;span style="font-style: italic;"&gt;replacement&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;First, we have a &lt;a href="http://www.perl.org"&gt;perl&lt;/a&gt; one liner:&lt;br /&gt;perl -pi -e 's/orig/replacement/g' file&lt;br /&gt;&lt;br /&gt;And here we do the same with &lt;a href="http://www.gnu.org/software/sed/manual/"&gt;sed&lt;/a&gt;:&lt;br /&gt;sed -i -e 's/orig/replacement/g' file&lt;br /&gt;&lt;br /&gt;This example finds and replaces a simple string in a file. You can also use a regex (&lt;a href="http://www.regular-expressions.info/reference.html"&gt;regular expression&lt;/a&gt;) to do more powerful substitutions.&lt;br /&gt;&lt;br /&gt;To replace all words that begin abb with ABB in /usr/share/dict/words:&lt;br /&gt;sed -i -e 's/^abb/ABB/g' /usr/share/dict/words&lt;br /&gt;&lt;br /&gt;$ egrep '^abd' /usr/share/dict/words&lt;br /&gt;abdomen&lt;br /&gt;abdomens&lt;br /&gt;abdominal&lt;br /&gt;abduct&lt;br /&gt;abducted&lt;br /&gt;abduction&lt;br /&gt;abductions&lt;br /&gt;abductor&lt;br /&gt;abductors&lt;br /&gt;abducts&lt;br /&gt;$ sed -i -e 's/^abb/ABB/g' /usr/share/dict/words&lt;br /&gt;$ egrep '^abb' /usr/share/dict/words&lt;br /&gt;$ egrep '^ABB' /usr/share/dict/words&lt;br /&gt;ABBe&lt;br /&gt;ABBey&lt;br /&gt;ABBeys&lt;br /&gt;ABBot&lt;br /&gt;ABBots&lt;br /&gt;ABBreviate&lt;br /&gt;ABBreviated&lt;br /&gt;ABBreviates&lt;br /&gt;ABBreviating&lt;br /&gt;ABBreviation&lt;br /&gt;ABBreviations&lt;br /&gt;$&lt;br /&gt;&lt;br /&gt;Of course I used a copy of the words file and didn't actually clobber the original.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3602443957408805914-4892209953986631884?l=tributetogrr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tributetogrr.blogspot.com/feeds/4892209953986631884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3602443957408805914&amp;postID=4892209953986631884' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/4892209953986631884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/4892209953986631884'/><link rel='alternate' type='text/html' href='http://tributetogrr.blogspot.com/2008/05/inline-search-and-replacement-one.html' title='Inline Search and Replacement One Liners'/><author><name>David</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3602443957408805914.post-1311532194641788868</id><published>2008-04-25T09:57:00.004-04:00</published><updated>2008-04-28T23:49:26.908-04:00</updated><title type='text'>Patch Your Linux Kernel and Apply Code Without Rebooting</title><content type='html'>&lt;a href="http://web.mit.edu/ksplice"&gt;KSplice&lt;/a&gt; from MIT allows you to apply security patches to your running Linux kernel without rebooting. This is great news for organizations that can not reboot their systems. KSplice would primarily be used to apply security updates as it is limited to making code changes that do not introduce semantic changes to data structures. Therefore, KSplice is best used to apply security updates that fix "off by one" and similar style exploits.&lt;br /&gt;&lt;br /&gt;Check out the project at &lt;a href="http://web.mit.edu/ksplice"&gt;http://web.mit.edu/ksplice&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;David&lt;br /&gt;&lt;a href="http://tributetogrr.blogspot.com/"&gt;http://tributetogrr.blogspot.com&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3602443957408805914-1311532194641788868?l=tributetogrr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tributetogrr.blogspot.com/feeds/1311532194641788868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3602443957408805914&amp;postID=1311532194641788868' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/1311532194641788868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/1311532194641788868'/><link rel='alternate' type='text/html' href='http://tributetogrr.blogspot.com/2008/04/patch-your-linux-kernel-and-apply-code.html' title='Patch Your Linux Kernel and Apply Code Without Rebooting'/><author><name>David</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3602443957408805914.post-2843483256185627970</id><published>2008-04-16T12:41:00.002-04:00</published><updated>2008-04-16T14:00:27.589-04:00</updated><title type='text'>Multiple Ways to Delete Blank Lines From a Text File</title><content type='html'>You have a text file that has a bunch of blank lines in it. You want to do some operation on that text file but first want to delete the blank lines. You could open the file in vi and manually delete them all but that isn't the Unix way. Here are a number of easy ways to delete blank lines.&lt;br /&gt;&lt;br /&gt;If you already have the text file open in vi/vim, the following will delete all blank lines while in command mode:&lt;br /&gt;:g/^$/d&lt;br /&gt;&lt;br /&gt;Here are a few different options from the shell using standard GNU tools:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.gnu.org/software/gawk/gawk.html"&gt;GNU awk&lt;/a&gt;&lt;br /&gt;&lt;blockquote&gt;awk '/./' filename&lt;/blockquote&gt;&lt;blockquote&gt;awk 'NF &gt; 0' filename&lt;/blockquote&gt; Warning: This will delete all blank lines AND lines containing only whitespace&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.gnu.org/software/sed/sed.html"&gt;GNU sed&lt;/a&gt;&lt;br /&gt;&lt;blockquote&gt;sed -i '/^$/d' filename&lt;/blockquote&gt;This makes use of the regular expression ^$ representing blank lines. The -i flag tells sed to edit the file in place. If you want to preserve the original file, simple remove the -i and redirect the output to a new file:&lt;br /&gt;&lt;blockquote&gt;sed '/^$/d' filename &gt; newfilename&lt;/blockquote&gt;&lt;a href="http://www.gnu.org/software/grep/grep.html"&gt;GNU grep&lt;/a&gt;&lt;br /&gt;&lt;blockquote&gt;grep -v '^$' filename &gt; newfilename&lt;/blockquote&gt;This is the same as sed with the use of the regex ^$&lt;br /&gt;&lt;br /&gt;Of course there are many other ways to accomplish this task. That is the beauty of Unix.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3602443957408805914-2843483256185627970?l=tributetogrr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tributetogrr.blogspot.com/feeds/2843483256185627970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3602443957408805914&amp;postID=2843483256185627970' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/2843483256185627970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/2843483256185627970'/><link rel='alternate' type='text/html' href='http://tributetogrr.blogspot.com/2008/04/multiple-ways-to-delete-blank-lines.html' title='Multiple Ways to Delete Blank Lines From a Text File'/><author><name>David</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3602443957408805914.post-7329066659878977918</id><published>2008-04-11T21:51:00.002-04:00</published><updated>2008-04-13T13:33:07.169-04:00</updated><title type='text'>Display the Contents of an RPM or Tar Archive</title><content type='html'>An RPM is just an archive of files. I believe that all of the various archiving programs (tar, cpio, etc.) provide you with a way to list the contents of their archives. An RPM is no different. You need to figure out if foo.rpm provides libfoo.so. Making use of the rpm2cpio, cpio, and grep programs, we can do just this:&lt;br /&gt;&lt;br /&gt;unix% rpm2cpio foo.rpm | cpio -t | grep "libfoo.so"&lt;br /&gt;/usr/lib/libfoo.so.2&lt;br /&gt;unix%&lt;br /&gt;&lt;br /&gt;Conversely, you can display the contents of a tar archive in one step:&lt;br /&gt;unix% tar -tvf foo.tar&lt;br /&gt;foo/&lt;br /&gt;foo/bar.txt&lt;br /&gt;foo/bills&lt;br /&gt;foo/private/&lt;br /&gt;foo/private/tax-return.pdf&lt;br /&gt;unix%&lt;br /&gt;&lt;br /&gt;Neither of these steps will actually extract files from the archive.&lt;br /&gt;&lt;br /&gt;Being a diehard Debian user, it feels weird to write my first post about an RPM tip. By day, I admin a large number of Suse servers for a financial company. For me, there is no escaping the dreaded RPM.&lt;br /&gt;&lt;br /&gt;Unix questions are always welcome.&lt;br /&gt;Send questions to unix@tributetogrr.blogspot.com&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!--&lt;br /&gt;google_ad_client = "pub-6730448982005967";&lt;br /&gt;/* 234x60, created 4/13/08 */&lt;br /&gt;google_ad_slot = "1103472883";&lt;br /&gt;google_ad_width = 234;&lt;br /&gt;google_ad_height = 60;&lt;br /&gt;//--&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&lt;br /&gt;src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3602443957408805914-7329066659878977918?l=tributetogrr.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tributetogrr.blogspot.com/feeds/7329066659878977918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3602443957408805914&amp;postID=7329066659878977918' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/7329066659878977918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3602443957408805914/posts/default/7329066659878977918'/><link rel='alternate' type='text/html' href='http://tributetogrr.blogspot.com/2008/04/display-contents-of-rpm-or-tar-archive.html' title='Display the Contents of an RPM or Tar Archive'/><author><name>David</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
