<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: ps code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 00:39:29 GMT</pubDate>
    <description>DZone Snippets: ps code</description>
    <item>
      <title>Copy all svn:* properties from one file to another</title>
      <link>http://snippets.dzone.com/posts/show/5501</link>
      <description>The following script can be used to copy all SVN properties from one file (presumably a file that's already under SVN control) to another file (which you presumably want to put under SVN control, and which you want to check in with the same SVN properties).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;ORIG=$1 ; shift ;&lt;br /&gt;[ -e "$ORIG" ] || exit ;&lt;br /&gt;&lt;br /&gt;for PROP in `svn pl "$ORIG" | sed -n '2,$p'` ; do&lt;br /&gt;        VALUE=`svn pg $PROP "$ORIG"` ;&lt;br /&gt;        for FILE ; do&lt;br /&gt;                [ -e "$FILE" ] &amp;&amp; svn ps $PROP "$VALUE" "$FILE" ;&lt;br /&gt;        done&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;# That's it, Folks!&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you put the above code in a shell script called...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;svnprops.sh&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;... then you can run it as follows if you want to copy all svn:* properties FROM original.file TO blegga:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;pvdb@localhost ~ $ ./svnprops.sh original.file blegga &lt;br /&gt;property 'svn:mime-type' set on 'blegga'&lt;br /&gt;property 'svn:eol-style' set on 'blegga'&lt;br /&gt;pvdb@localhost ~ $ _&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;... or as follows for multiple target files:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;pvdb@localhost ~ $ ./svnprops.sh another.original.file blegga foo bar &lt;br /&gt;property 'svn:mime-type' set on 'blegga'&lt;br /&gt;property 'svn:mime-type' set on 'foo'&lt;br /&gt;property 'svn:mime-type' set on 'bar'&lt;br /&gt;pvdb@localhost ~ $ _ &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Fri, 16 May 2008 11:25:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5501</guid>
      <author>pvdb (Peter Vandenberk)</author>
    </item>
    <item>
      <title>substitution for 'ps -aux | grep [P]ROCESS'</title>
      <link>http://snippets.dzone.com/posts/show/2640</link>
      <description>as we know, invoking grep after ps with first letter of the PROCESS enclosed in brackets [] (like this: ps -aux | grep [P]ROCESS), excludes grep PROCESS from the output. so, instead of typing those brackets manualy every time, we may use the code below:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'`&lt;br /&gt;REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'`&lt;br /&gt;ps -aux | grep "[$FIRST]$REST"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;you may use it as separate shell-script -- like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'`&lt;br /&gt;REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'`&lt;br /&gt;ps -aux | grep -v "full/path/to/your/script" | grep "[$FIRST]$REST"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;or just include it in your .bashrc or similar -- like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function psg&lt;br /&gt;{&lt;br /&gt;FIRST=`echo $1 | sed -e 's/^\(.\).*/\1/'`&lt;br /&gt;REST=`echo $1 | sed -e 's/^.\(.*\)/\1/'`&lt;br /&gt;ps -aux | grep "[$FIRST]$REST"&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 22 Sep 2006 09:47:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2640</guid>
      <author>dsjkvf (dsjkvf)</author>
    </item>
  </channel>
</rss>
