how do I view previously typed commands in the csh ?

  • Follow


If I'm logged in under csh, how do I view the last, say, 10 to 50
commands that I've typed in the shell?

Also, if I'm logged in as root, how do I view the last 10 to 50
commands that I've typed in the shell?  Thanks.
0
Reply serendipity1276 (27) 6/12/2009 8:23:39 AM

On Fri, 12 Jun 2009, Michelle wrote:

> If I'm logged in under csh, how do I view the last, say, 10 to 50
> commands that I've typed in the shell?

Use the history command, provided history has been set up.  But why
are you using csh?  There are several other, better choices (e.g.,
ksh).

> Also, if I'm logged in as root, how do I view the last 10 to 50
> commands that I've typed in the shell?  Thanks.

Depends what shell.

-- 
Rich Teer, SCSA, SCNA, SCSECA

URLs: http://www.rite-group.com/rich
      http://www.linkedin.com/in/richteer
0
Reply Rich 6/12/2009 3:31:40 PM


Rich Teer wrote:
> On Fri, 12 Jun 2009, Michelle wrote:
> 
>> If I'm logged in under csh, how do I view the last, say, 10 to 50
>> commands that I've typed in the shell?
> 
> Use the history command, provided history has been set up.  But why
> are you using csh?  There are several other, better choices (e.g.,
> ksh).

I think that the choice of shell is a religious issue!  They all seem to 
get the job done somehow or other.  What little training I got featured 
the Korn shell so ksh is what I use by preference.  The Bourne shell is 
used for things like startup and shutdown on most systems.  I think it 
best to leave it that way.  YMMV

What users choose to use as a shell is entirely up to them.  If they're
not using sh or ksh I can't help them much.
0
Reply Richard 6/12/2009 8:47:48 PM

Hi,

Rich Teer wrote:
> On Fri, 12 Jun 2009, Michelle wrote:
> 
>> If I'm logged in under csh, how do I view the last, say, 10 to 50
>> commands that I've typed in the shell?
> 
> Use the history command, provided history has been set up.  But why
> are you using csh?  There are several other, better choices (e.g.,
> ksh).
You can't be serius for a "normal" user to use ksh over csh, if hw 
should change he should change to tcsh or bash

ksh is for the real hard ones :)

> 
>> Also, if I'm logged in as root, how do I view the last 10 to 50
>> commands that I've typed in the shell?  Thanks.
> 
> Depends what shell.
> 

/michael

0
Reply Michael 6/12/2009 9:22:45 PM

Hi,.

Michelle wrote:
> If I'm logged in under csh, how do I view the last, say, 10 to 50
> commands that I've typed in the shell?
> 
> Also, if I'm logged in as root, how do I view the last 10 to 50
> commands that I've typed in the shell?  Thanks.
You should set a variable named history to a number taht corresponds to 
the number of commands to store
% set history = 20 (you could store this in a file like ~/.cshrc)

% ls

% echo "hello"

% history


purify2% history
      3  set history = 20
      4  ls
      5  echo "hello"
      6  history

Or you could try bash or tcsh at the command line, that means change the 
shell after each login

% bash

or

% tcsh

Then you could use arrow-up and so for retrieving old commands


/michael
0
Reply Michael 6/12/2009 9:28:37 PM

On Jun 12, 4:23=A0am, Michelle <serendipity1...@yahoo.com> wrote:
> If I'm logged in under csh, how do I view the last, say, 10 to 50
> commands that I've typed in the shell?
>
> Also, if I'm logged in as root, how do I view the last 10 to 50
> commands that I've typed in the shell? =A0Thanks.

% history

You can even grep through it find the command you want:

% history | grep -i <some command>

Then you run it will a ! and the number that show up in the left hand
column.

% !455
0
Reply Robert 6/13/2009 1:48:14 AM

On 2009-06-12 10:23:39 +0200, Michelle <serendipity1276@yahoo.com> said:

> If I'm logged in under csh, how do I view the last, say, 10 to 50
> commands that I've typed in the shell?
> 
> Also, if I'm logged in as root, how do I view the last 10 to 50
> commands that I've typed in the shell?  Thanks.

michelle,

you can use the fc or history built-in command for shells like zsh, ksh 
or bash.

'fc -l' will list recently executed commands

'fc' allone will start an editor session for the most recently used command

chris

-- 
CHRIS ECKERT
eckert[at]alphanet.ch - http://www.alphanet.ch/~eckert
gpg public key id 0xD08960E3

0
Reply Chris 6/13/2009 9:50:26 AM

On Fri, 12 Jun 2009, Richard B. Gilbert wrote:

> What users choose to use as a shell is entirely up to them.  If they're
> not using sh or ksh I can't help them much.

True and I agree.  But the nature of the question suggested to me that Michelle
was a new user, not weddded to any particular shell.  In this instance I was
suggesting that there are better shells for a newbie to learn.  Old csh hands
are of course welcome to use their shell of choice, but they're also not likely
to ask newbie questions that a glimpse of the man page could've answered.

-- 
Rich Teer, SCSA, SCNA, SCSECA

URLs: http://www.rite-group.com/rich
      http://www.linkedin.com/in/richteer
0
Reply Rich 6/13/2009 3:37:37 PM

On Jun 13, 8:37 am, Rich Teer <rich.t...@rite-group.com> wrote:
> On Fri, 12 Jun 2009, Richard B. Gilbert wrote:
> > What users choose to use as a shell is entirely up to them.  If they're
> > not using sh or ksh I can't help them much.
>
> True and I agree.  But the nature of the question suggested to me that Michelle
> was a new user, not weddded to any particular shell.  In this instance I was
> suggesting that there are better shells for a newbie to learn.

Ah -- taking this opportunity to proselytize, eh?  :-)

I'm starting to like bash.  It is another Bourne Shell
derivative with a more PC-like history mechanism, and
appears to be the default shell on all the Linux boxen.
As I get to know it better, I have fewer things to
remember between Linux and Solaris.

Even better, I've just discovered you can configure it
to use either vi-like command editing like ksh.  So with
some minor tweaking, I have even fewer things to remember.

(By "things to remember", I mean stuff like little things
that are different -- like jumping back and forth between
Delphi (Pascal-based) and Java (C-based), where in one you
have apostrophe string quotes ('), colon-equal assignment
(:=), and single-equal comparison (=), but in the other you
have double-quotes ("), single-equal (=) and double (==).
It's very annoying when you repeatedly use the wrong one!)

\:-\
0
Reply ThanksButNo 6/13/2009 11:15:37 PM

Hi,

ThanksButNo wrote:
> On Jun 13, 8:37 am, Rich Teer <rich.t...@rite-group.com> wrote:
>> On Fri, 12 Jun 2009, Richard B. Gilbert wrote:
>>> What users choose to use as a shell is entirely up to them.  If they're
>>> not using sh or ksh I can't help them much.
>> True and I agree.  But the nature of the question suggested to me that Michelle
>> was a new user, not weddded to any particular shell.  In this instance I was
>> suggesting that there are better shells for a newbie to learn.
> 
> Ah -- taking this opportunity to proselytize, eh?  :-)
> 
> I'm starting to like bash.  It is another Bourne Shell
> derivative with a more PC-like history mechanism, and
> appears to be the default shell on all the Linux boxen.
> As I get to know it better, I have fewer things to
> remember between Linux and Solaris.
> 
> Even better, I've just discovered you can configure it
> to use either vi-like command editing like ksh.  So with
> some minor tweaking, I have even fewer things to remember.
> 
> (By "things to remember", I mean stuff like little things
> that are different -- like jumping back and forth between
> Delphi (Pascal-based) and Java (C-based), where in one you
> have apostrophe string quotes ('), colon-equal assignment
> (:=), and single-equal comparison (=), but in the other you
> have double-quotes ("), single-equal (=) and double (==).
> It's very annoying when you repeatedly use the wrong one!)
> 
> \:-\
bash is for sure the way to go especially if you use NIS in a mixed 
environment where both Solaris and Linux is since Linux use ONLY bash!

/michael
0
Reply Michael 6/14/2009 8:51:37 AM

ThanksButNo <no.no.thanks@gmail.com> writes:

>Even better, I've just discovered you can configure it
>to use either vi-like command editing like ksh.  So with
>some minor tweaking, I have even fewer things to remember.

You like that?  Both ksh and ksh93 alow "emacs style" command editing.

I like "vi" for my editor, by I use emacs for my command shell.

Casper
-- 
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
0
Reply Casper 6/14/2009 1:58:03 PM

On Jun 14, 7:58=A0am, Casper H.S. Dik <Casper....@Sun.COM> wrote:
> ThanksButNo <no.no.tha...@gmail.com> writes:
> >Even better, I've just discovered you can configure it
> >to use either vi-like command editing like ksh. =A0So with
> >some minor tweaking, I have even fewer things to remember.
>
> You like that? =A0Both ksh and ksh93 alow "emacs style" command editing.
>
> I like "vi" for my editor, by I use emacs for my command shell.
>
> Casper
> --
> Expressed in this posting are my opinions. =A0They are in no way related
> to opinions held by my employer, Sun Microsystems.
> Statements on Sun products included here are not gospel and may
> be fiction rather than truth.

do a ksh -o vi and use vi like stuff....esc-k esc-j...you'll still be
using csh(you forked a ksh from there) and you'll have history.....or
just more the history file...it'll be .*history*(something with
history or hist in it)....just kidding...

I remember a job where my manager did not want me to see his(my
manager's) history file...I was starting the job...wanted to learn...

Kartik Vashishta
0
Reply kartikvashishta108 6/15/2009 1:07:14 AM

ThanksButNo <no.no.thanks@gmail.com> wrote:
> On Jun 13, 8:37 am, Rich Teer <rich.t...@rite-group.com> wrote:
>> On Fri, 12 Jun 2009, Richard B. Gilbert wrote:
>> > What users choose to use as a shell is entirely up to them.  If they're
>> > not using sh or ksh I can't help them much.
>>
>> True and I agree.  But the nature of the question suggested to me that Michelle
>> was a new user, not weddded to any particular shell.  In this instance I was
>> suggesting that there are better shells for a newbie to learn.
> 
> Ah -- taking this opportunity to proselytize, eh?  :-)
> 
> I'm starting to like bash.  It is another Bourne Shell
> derivative with a more PC-like history mechanism, and
> appears to be the default shell on all the Linux boxen.
> As I get to know it better, I have fewer things to
> remember between Linux and Solaris.
> 
> Even better, I've just discovered you can configure it
> to use either vi-like command editing like ksh.  So with
> some minor tweaking, I have even fewer things to remember.

(some snipping)

Mostly true. You can do vi (or emacs) style command line editing in
ksh as well.

The thing is, bash is not Bourne shell compatible. It's _mostly_
compatible, but there are things in sh scripts that do not work
with bash, even after all of these years.

Colin
0
Reply Colin 6/15/2009 9:57:24 PM

12 Replies
226 Views

(page loaded in 0.581 seconds)

Similiar Articles:









7/20/2012 1:38:18 PM


Reply: