<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: alias in ksh in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912152#M933754</link>
    <description>If you are running csh now, why are you wanting to use "ksh"?&lt;BR /&gt;&lt;BR /&gt;If you are trying to make alias definitions that are interchangable between the 2 shells, then I think you won't be able to do that.&lt;BR /&gt;&lt;BR /&gt;If you are converting over to "ksh" and dropping "csh" as your primary shell, then you can convert all your aliases to functions, place them in ".profile" to set them at login.&lt;BR /&gt;It is pretty easy to convert the alias to a function. example-&lt;BR /&gt;alias psg='ps -ef | grep -i  | grep -v grep'&lt;BR /&gt;&lt;BR /&gt;becomes&lt;BR /&gt;&lt;BR /&gt;function psg {ps -ef | grep -i $1 | grep -v }&lt;BR /&gt;&lt;BR /&gt;You could build these functions by replacting the following-&lt;BR /&gt;"alias" with "function"&lt;BR /&gt;"='" with "{"&lt;BR /&gt;trailing "'" with "}".&lt;BR /&gt;&lt;BR /&gt;If you have a lot, you could use sed or awk or perl to build up .profile.&lt;BR /&gt;&lt;BR /&gt;Aliases under ksh only do "word" substitutions at the beginning of a command. Their is no equivalent .&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Tue, 25 Feb 2003 19:14:56 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2003-02-25T19:14:56Z</dc:date>
    <item>
      <title>alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912140#M933742</link>
      <description>I want to setup an alias 'psg' which, when given a parameter, would give me processes grep-ed by that parameter, viz.&lt;BR /&gt;&lt;BR /&gt;psg oracle (would list all procs which has oracle word in them)&lt;BR /&gt;&lt;BR /&gt;psg http (all procs with http word in them)&lt;BR /&gt;&lt;BR /&gt;alias=`ps -ef|grep -i |grep -v grep'&lt;BR /&gt;&lt;BR /&gt;I was able to do the above in csh by substituting  with \!*&lt;BR /&gt;&lt;BR /&gt;What is the corresponding string for ksh?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;...Manjeet</description>
      <pubDate>Mon, 24 Feb 2003 22:58:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912140#M933742</guid>
      <dc:creator>Kellogg Unix Team</dc:creator>
      <dc:date>2003-02-24T22:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912141#M933743</link>
      <description>alias psg=`ps ....`&lt;BR /&gt;&lt;BR /&gt;Sorry for the typo!</description>
      <pubDate>Mon, 24 Feb 2003 23:00:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912141#M933743</guid>
      <dc:creator>Kellogg Unix Team</dc:creator>
      <dc:date>2003-02-24T23:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912142#M933744</link>
      <description>Aliases aren't very smart in ksh. Better to use function.&lt;BR /&gt;&lt;BR /&gt;example-&lt;BR /&gt;function psg {ps -ef | grep $1 | grep -v "grep"}&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Mon, 24 Feb 2003 23:34:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912142#M933744</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-02-24T23:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912143#M933745</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Should be &lt;BR /&gt;&lt;BR /&gt;ps -ef | grep -i $1 | grep -v grep&lt;BR /&gt;&lt;BR /&gt;$X where X is numeric are argument vars. &lt;BR /&gt;$0 = command&lt;BR /&gt;$1 = 1st argument&lt;BR /&gt;$2 = 2nd argument&lt;BR /&gt;etc.&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;Jeff</description>
      <pubDate>Tue, 25 Feb 2003 00:27:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912143#M933745</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2003-02-25T00:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912144#M933746</link>
      <description>So you could even *extend* that alias command by simply defining it to be:&lt;BR /&gt;&lt;BR /&gt;ps -ef | grep -i -e $1 -e $2 -e $3 ....etc | grep -v grep&lt;BR /&gt;&lt;BR /&gt;And then you could do&lt;BR /&gt;&lt;BR /&gt;psg oracle http java&lt;BR /&gt;&lt;BR /&gt;and get all procs with any of those.&lt;BR /&gt;&lt;BR /&gt;Jeff</description>
      <pubDate>Tue, 25 Feb 2003 00:31:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912144#M933746</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2003-02-25T00:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912145#M933747</link>
      <description>The easiest is to use a separate script rather than an alias as you could limit which fields will be used for the comparison. However, to find all processes owned by the oracle user, use ps options:&lt;BR /&gt;&lt;BR /&gt;ps -f -u oracle&lt;BR /&gt;&lt;BR /&gt;Or to search for a specific process (and not locate processes with unrelated strings), use the -C option:&lt;BR /&gt;&lt;BR /&gt;UNIX95= ps -f -C sh&lt;BR /&gt;&lt;BR /&gt;which will NOT find ksh like grep does.</description>
      <pubDate>Tue, 25 Feb 2003 05:17:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912145#M933747</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2003-02-25T05:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912146#M933748</link>
      <description>just a note while setting alias in ksh you should give ' (forward slash) not the ` (back slash). &lt;BR /&gt;&lt;BR /&gt;I do not know how to replace your ??? of csh but why not just do ps instead of writting a function. I think ps is given for this purpose. &lt;BR /&gt;&lt;BR /&gt;Use as many standard commands as you can before writting your own functions, otherwise it will only complicate things further.&lt;BR /&gt;&lt;BR /&gt;hope this helps..&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Feb 2003 09:18:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912146#M933748</guid>
      <dc:creator>monasingh_1</dc:creator>
      <dc:date>2003-02-25T09:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912147#M933749</link>
      <description>Rodney,&lt;BR /&gt;&lt;BR /&gt;How would I make use of this function? Do I include it in a script? &lt;BR /&gt;&lt;BR /&gt;psg is just an example; I have many aliases defined that way in my .cshrc. That will mean writing scripts for all of them!&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 25 Feb 2003 15:56:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912147#M933749</guid>
      <dc:creator>Kellogg Unix Team</dc:creator>
      <dc:date>2003-02-25T15:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912148#M933750</link>
      <description>Jeff S.&lt;BR /&gt;&lt;BR /&gt;$1 doesn't work in alias.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 25 Feb 2003 15:59:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912148#M933750</guid>
      <dc:creator>Kellogg Unix Team</dc:creator>
      <dc:date>2003-02-25T15:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912149#M933751</link>
      <description>Bill H.&lt;BR /&gt;&lt;BR /&gt;Its not a single alias that I am trying to work. I have lot many and writing scripts for them may be an overkill. But so far, what I am learning from user-community is that ksh doesn't have that feature.&lt;BR /&gt;&lt;BR /&gt;Thanks for the tip for -C flag. How would I use it?</description>
      <pubDate>Tue, 25 Feb 2003 16:05:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912149#M933751</guid>
      <dc:creator>Kellogg Unix Team</dc:creator>
      <dc:date>2003-02-25T16:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912150#M933752</link>
      <description>Monasingh&lt;BR /&gt;&lt;BR /&gt;Good catch! It should be forward tick and not reverse tick as I put in my initial post.&lt;BR /&gt;&lt;BR /&gt;Writing aliases and functions saves time and make things go faster. I would rather type "psg http" than "ps -ef|grep http|grep -v grep" every time I have to look for http procs. Just my personal preference! &lt;BR /&gt;:-)</description>
      <pubDate>Tue, 25 Feb 2003 16:13:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912150#M933752</guid>
      <dc:creator>Kellogg Unix Team</dc:creator>
      <dc:date>2003-02-25T16:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912151#M933753</link>
      <description>You use the function like an alias-&lt;BR /&gt;&lt;BR /&gt;psg oracle&lt;BR /&gt;&lt;BR /&gt;will display processes with name "oracle".&lt;BR /&gt;&lt;BR /&gt;Give it a try, I think it will do what you want.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 25 Feb 2003 19:01:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912151#M933753</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-02-25T19:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912152#M933754</link>
      <description>If you are running csh now, why are you wanting to use "ksh"?&lt;BR /&gt;&lt;BR /&gt;If you are trying to make alias definitions that are interchangable between the 2 shells, then I think you won't be able to do that.&lt;BR /&gt;&lt;BR /&gt;If you are converting over to "ksh" and dropping "csh" as your primary shell, then you can convert all your aliases to functions, place them in ".profile" to set them at login.&lt;BR /&gt;It is pretty easy to convert the alias to a function. example-&lt;BR /&gt;alias psg='ps -ef | grep -i  | grep -v grep'&lt;BR /&gt;&lt;BR /&gt;becomes&lt;BR /&gt;&lt;BR /&gt;function psg {ps -ef | grep -i $1 | grep -v }&lt;BR /&gt;&lt;BR /&gt;You could build these functions by replacting the following-&lt;BR /&gt;"alias" with "function"&lt;BR /&gt;"='" with "{"&lt;BR /&gt;trailing "'" with "}".&lt;BR /&gt;&lt;BR /&gt;If you have a lot, you could use sed or awk or perl to build up .profile.&lt;BR /&gt;&lt;BR /&gt;Aliases under ksh only do "word" substitutions at the beginning of a command. Their is no equivalent .&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 25 Feb 2003 19:14:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912152#M933754</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-02-25T19:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912153#M933755</link>
      <description>Rodney,&lt;BR /&gt;&lt;BR /&gt;Thanks. The function works the following way -&lt;BR /&gt;&lt;BR /&gt;psg() {&lt;BR /&gt;   ps -ef|grep -i $1|grep -v grep&lt;BR /&gt;      }&lt;BR /&gt;&lt;BR /&gt;I can include my other aliases this way.&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;...Manjeet</description>
      <pubDate>Tue, 25 Feb 2003 23:17:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912153#M933755</guid>
      <dc:creator>Kellogg Unix Team</dc:creator>
      <dc:date>2003-02-25T23:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: alias in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912154#M933756</link>
      <description>The -C option (and -H and -o) are all 'special' features that are enabled via the XPG4 option. The man page is a bit cryptic about how to set it, but all that is necessary is to set the environment variable UNIX95. In the above example:&lt;BR /&gt;&lt;BR /&gt;UNIX95= ps -f -C sh&lt;BR /&gt;&lt;BR /&gt;The UNIX95= simply defines the variable with a null value (UNIX95 can be anything including null) and in POSIX shells like ksh, the variable assignment can be placed in front of the command. Without UNIX95= then ps doesn't know what to do with -C&lt;BR /&gt;&lt;BR /&gt;The primary advantage of -C is that ps searches the EXACT match of the program name (and not the pathname or username or anything else). Thus:&lt;BR /&gt;&lt;BR /&gt;UNIX95= ps -f -C java&lt;BR /&gt;&lt;BR /&gt;will not find any users with java in their name (like java or hotjava) nor will it find processes with a pathname such as /opt/java/bin/java3) because it looks just at the process name.&lt;BR /&gt;&lt;BR /&gt;-H is pretty nifty when looking for a hierarchy of parents and children, and -o allows you to construct your own version of ps as in:&lt;BR /&gt;&lt;BR /&gt;UNIX95= ps -e -o vsz,pid,args | sort -rn&lt;BR /&gt;&lt;BR /&gt;which shows the resident set size of all prgrams, their PID and the command line, then sorted by VSZ (which is in Kbytes)</description>
      <pubDate>Thu, 27 Feb 2003 02:40:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/alias-in-ksh/m-p/2912154#M933756</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2003-02-27T02:40:37Z</dc:date>
    </item>
  </channel>
</rss>

