Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

! nn and !! with ksh

Posted on 2001-06-24
14
Medium Priority
?
1,113 Views
Last Modified: 2010-04-21
Hi all,

Now I can use ksh from csh but I face another issues :
- when I enter !! it raises ksh: !!: not found
- when I want to reexecute a command under ksh e.g. : ! nn, it have : ksh: 114: not found.

Thanks in advance.
0
Comment
Question by:Richard Coffre
14 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 150 total points
ID: 6223778
Hi  pyxos,

     Now you can put :
     EDITOR=vi
     export EDITOR
     in your .profile
     
and
     put
     set -o vi
     in your .kshrc file

after that when you usr ksh, and type in
     . $HOME/.profile
     . $HOME/.kshrc

      you can use <Esc> k to serach you command line history

or  type in:
     <Esc> k /<serch-patten>  to search you commands from the
history.
     this command line editor behave like the vi editor, you can edit you
command use the same keys as vi.

     I hope this information help.

     Regards
          yuzh
     

0
 
LVL 11

Expert Comment

by:griessh
ID: 6224968
Another way (I like this one even more)

In your .env file, add:

set -o emacs

# Arrows
#
alias __A=^P                    # uparrow
alias __B=^N                    # down arrow
alias __C=^F                    # left arrow
alias __D=^B                    # right arrow

to use the arrow keys on your keyboard to go back and forth in your history.

(The ^P is a Ctrl+P key, same for the others ...)

======
Werner
0
 
LVL 8

Expert Comment

by:mnashadka
ID: 6225834
If you're using the vi editor as yuzh suggested, r nn is the same as !nn:
>history
1 ls
2 cd /
3 grep "hello" file

>r 2
cd /
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Richard Coffre
ID: 6226553
Hi Werner,

When is the file .env loaded ?
Do I have to source it manually ?

Thanks ina advance
0
 
LVL 11

Expert Comment

by:griessh
ID: 6227389
No, as soon as you type your "ksh" the shell will source your .env file (locate it in your home directory). To test (I use that to debug these scripts) just put a "echo Now in .env" in the first line of .env. You should see that text as soon as you start ksh.

======
Werner  
0
 
LVL 11

Expert Comment

by:griessh
ID: 6227414
And if it is not working, ksh is looking for an environment variable 'ENV' that points to the .env file.
So you should set in your cshell login:

setenv ENV=$HOME/.env

======
Werner
0
 
LVL 11

Expert Comment

by:griessh
ID: 6227428
And if you need a good book, try "Bolsky/Korn : The New Kornshell, command and programming Language" (Prentice Hall PTR)

======
Werner
0
 
LVL 38

Expert Comment

by:yuzh
ID: 6227952
Hi pyxos,

   Not all favour of UNIX system come with .env now. eg. Solaris, SCO and Debian (Linux) etc. that's why I tell you
to put:
   export ENV=$HOME/.kshrc in your .profile
   by the way, the env command tell you all your enviroment
variables settings.

   "source" is a csh/tcsh term!
   If you default shell is ksh, when you login, it first look at .profile and .kshrc file in your home dir, otherwise, it look for a systems wide profile file.

  I hope that this infor help.

Regards
  yuzh

   
0
 
LVL 38

Expert Comment

by:yuzh
ID: 6227984
Hi pyxos,

   As Werner said, if yor prefer to use emacs, you just need to replace my vi with emacs and put it in your .profile or .kshrc file, it should work.
   I think vi is more powerfull.

Regards
   yuzh



0
 
LVL 11

Expert Comment

by:griessh
ID: 6228037
yuzh

>>  Not all favour of UNIX system come with .env now. eg. Solaris, SCO and Debian (Linux) etc. that's why I tell you
to put: export ENV=$HOME/.kshrc in your .profile

What do you mean with that?

It doesn't matter what name the file has. It is important that the ENV variable is set to point to that file! What would be more obvious to use .env for ENV?
Anyway, the .profile is the file used when your login shell is ksh, csh uses .login and .cshrc. So setting the ENV in .profile will only help when your login shell is ksh.

======
Werner
0
 
LVL 38

Expert Comment

by:yuzh
ID: 6229701
Hi griessh ,

   When people use something like:

    export ENV=File-name
    it will do the job as long as the file has all the ENV settings, by convention, the ksh people trend to use .kshrc as the file name.  

    Cheers

    yuzh


0
 
LVL 11

Expert Comment

by:griessh
ID: 6230926
yuzh

I doubt that. I know many people using the .env convention and if you look into the kornshell book I mentioned (oneof the authors is David Korn!) they use the .profile for login and the ENV variable without mentioning a name.

======
Werner
0
 
LVL 38

Expert Comment

by:yuzh
ID: 6233559
Hi Werner,

    I think the purpose for this website is for helpping people or getting help from other people, not for arguing.

    It happen I have a few books on my book case, please check them
out:
    The Korn Shell user & programming Manual
                     -by Anatole Olczak
     UNIX Clearly Explained
                     -by Richard L Petersen
     A Practical Guide to the UNIX System
                     -by M. G. Sobell
      SCO UNIX  user's manual

     And
     "Best UNIX Tips EVER"

     they all talking about .kshrc.


============== END======================================

yuzh
0
 
LVL 11

Expert Comment

by:griessh
ID: 6233584
yuzh

That's great! And David Korn uses .... ENV

======
Werner
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question