Get rid of ^M
- cat xxx | tr -d "\r"
- :%s/^M//g (in vi, ^M = Ctrl-V + Ctrl-M)
- sed -e 's/^M//g'
- tr -d $'\r' < xx > yy
Process ID
http://unix.stackexchange.com/questions/32576/how-to-get-subshells-pid-in-korn-shell-equivalent-of-bashpid- sub-shell id:
- readlink /proc/self
- p=$(exec sh -c 'echo $PPID')
- current shell id:
- $$
- read -r xxx _ </proc/self/stat (xxx=1st argv, _=rest of line)
- parent shell id:
- $PPID
- ps -p 12345678 -o ppid=
How to tell Korn shell version
https://community.oracle.com/thread/2251850[ "${ERRNO}" ] && echo ksh88 || echo ksh99
How to tell if login or interactive shell
- [[ $- == *i* ]] && echo 'Interactive' || echo 'Not interactive'
- case $- in *i*) echo "This shell is interactive";; *) echo "This is a script";; esac
- http://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell: interactive+login, non-interactive+login(rare), non-interactive+non-login, interactive+non-login,
- to see all options: echo $- (http://www.tutorialspoint.com/unix_commands/ksh.htm)
Ksh startup
- /etc/profile
- $HOME/.profile
- ksh's startup file(any file pointed to by ENV variable whether or not in login shell)