Monday, January 15, 2007

Korn Shell (ksh) vs. C Shell (csh)


Korn Shell (ksh) vs. C Shell (csh)

The BGUnix and BGResearch Unix systems use the Korn shell (ksh) instead of the C shell (csh). For those that are familiar with the C shell commands, the chart below illustrates some common Unix commands for both command sets. Those that are different using Korn shell commands are shown in color.

Command or feature (csh) bgunix (ksh)
Commands executed when logging in .login and .login-dec .profile
Commands executed with each process .cshrc and .cshrc-dec .kshrc
Display the contents of a file on the screen cat cat
Return to the login directory cd cd
Change default directory to directory-name cd directory-name cd directory-name
Clear the terminal screen clear clear
Copy file source to dest cp source dest cp source dest
Interrupt the execution of the current program [Control]-C [Control]-C
Logs off the system logout or [Control]-D exit or [Control]-d
List files waiting to be printed lpq lpq
Send a file to the printer cslpr filename cslpr filename
Lists the files in the current directory ls ls
Lists the files in the current directory, with more info. ls -l ls -l
Create a subdirectory called dir-name mkdir dir-name mkdir dir-name
Display information about a unix command man command man command
View a file one page at a time more filename more filename
Rename a file mv old-name new-name mv old-name new-name
Change your password passwd passwd
Save a session in a photo file photo log-file-name photo log-file-name
Create or edit a file vi filename or
pico filename
vi filename or
pico filename
Display the current default directory pwd pwd
Delete (remove) a file rm filename rm filename
Delete (remove) an empty directory rmdir dirname rmdir dirname
Redirect standard output to a file command > file command > file
Redirect standard output and errors to a file command >& file command > file 2>&1
Create an alias alias m more alias m='more'
Remove an alias unalias m unalias m
Reexecute the last command !! r
List command history history history
Reexecute the fifth command in the history list !5 r 5
Reexecute the last command that started with vi !vi r vi
Set interactive command line editor (Not available) set -o vi
Define a function (Not available) function fun { commands; }
Execute a function (Not available) fun
Represents home directory of current user ~ ~
Represents home directory of user jsmith ~jsmith ~jsmith
Represents current working directory (Not available) ~+
Represents previous working directory (Not available) ~-
Compile a g++ program g++ prog.cpp g++ prog.cpp
Compile a g++ program for use with debugger g++ prog.cpp g++ -g prog.cpp

For those who write shell scripts, there are significant differences between csh and ksh on bgunix. You will need more information to be able to write shell scripts with ksh.

To set your bgunix prompt to be the current working directory, add the following line to $HOME/.profile :
export PS1='$PWD>'

No comments: