Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing last command in ksh

Tags:

shell

sh

ksh

I am running Solaris and I was wondering how to run the last command with ksh. I know that in bash/sh you can do "!!" for the last command and !-N for "N minus the last command." What is the equivalent in KSH? Thank you in advance.

like image 261
n-2r7 Avatar asked Nov 01 '25 10:11

n-2r7


2 Answers

r, or Control + P. Korn shell doesn't implement csh/bash-style history, but you can manipulate the command history with fc (r is an alias for an fc invocation), or with set -o emacs or set -o vi you can use editor commands to search and modify previous commands.

like image 186
geekosaur Avatar answered Nov 04 '25 03:11

geekosaur


Use fc -s (SOME letter of last executed command)

like if the last executed command was cat sample.txt

use fc -s ca

like image 31
Subrata C Avatar answered Nov 04 '25 03:11

Subrata C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!