Operating System - Linux
1831543 Members
3594 Online
110025 Solutions
New Discussion

Filename Completion and History

 
SOLVED
Go to solution
Suren Selva_1
Advisor

Filename Completion and History

Hello,

I am using RedHat Enterprise Linux Version 2.1. Can someone answer the following questions?
1. Which shell is recommended for Sys Admin tasks? What is the Posix or Korn shell equivalents in Linux?
2. In the recommended shell, how can I setup filename completion and command line editing?

Thanks to all replies,
S. Selva
Live and let live!
11 REPLIES 11
Paul Cross_1
Respected Contributor

Re: Filename Completion and History

I think the overwhelming answer to this is: (drum roll please)...
bash.
/bin/bash (usually) is a bourne shell replacement with many many added features like filename completion (this is the default).
bash supports vi-style editing ala ksh as well (bash -o vi)
Stuart Browne
Honored Contributor

Re: Filename Completion and History

It depends on what you're used to, and what you'd like to be able to do.

I'd agree with Paul though, as 'bash' (the standard on most (if not all) Linux systems) is probably your best bet.

It comes started with file completion, and also a command history (usually stored in ~/.bash_history ($HISTFILE)) of configurable length ($HISTFILESIZE and $HISTSIZE).

The history navigation and inline editing are variable, and can be changed to use your favourite editor styled commands (set -o vi, set -o emacs), with or without arrow-key support.

As for ksh equivlants, you've got 'pdksh', as well as the standard posix 'ksh' source available to download and compile. Most linux distributions have a 'pdksh' package available, but due to the licencing, you'll need to get the posix ksh source yourslef.
One long-haired git at your service...
Suren Selva_1
Advisor

Re: Filename Completion and History

With 'set -o vi' I was able to do command line history editing.

However I am still unable to do filename completion by hitting the ESC key twice.

How can I get that done?

-Suren
Live and let live!
Paul Cross_1
Respected Contributor

Re: Filename Completion and History

Use the tab key ala tcsh...
or esc-k, esc-m, as in vi.
Suren Selva_1
Advisor

Re: Filename Completion and History

This is for moving up and down the command line is it not? Moving up and down works for me with set -o vi.

How can filename completion be done?

-Suren
Live and let live!
Jared Middleton
Frequent Advisor

Re: Filename Completion and History

I used to use ksh and SAM on our old HP-UX servers, but since we switched over to RH Linux, I found bash to be my new favorite shell. And even better than SAM, I love power, simplicity and ability to delegate specific functions using the web-based admin tool Webmin (www.webmin.com)

As Paul indicated, under bash, just enter the leading part of a file name path and hit the TAB key... just as you would do under ksh with the ESC key.

-Jared
Mark Grant
Honored Contributor
Solution

Re: Filename Completion and History

Suren, you need to press TAB twice if there is more than one file that could satisfy the completion.

For example, type "whic" and then the TAB key. It will immediately be completed to "which". However, if you type "wh" you have to press the TAB key twice to get a full list of all the files that could match.
Never preceed any demonstration with anything more predictive than "watch this"
Suren Selva_1
Advisor

Re: Filename Completion and History

Thanks to you all. I got it.

-Suren
Live and let live!
Steven E. Protter
Exalted Contributor

Re: Filename Completion and History

I also noticed recently that Red Hat Enterprise Server AS 3.0 Release 1 does take the HP-UX escape escape filename completion.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Tony Contratto
Respected Contributor

Re: Filename Completion and History

Another option...

If you want completion by pressing escape twice, you can install pdksh. Then use "set -o vi" to enable vi like command line editing and "set -o vi-esccomplete" to enable the double escape completion.

--
Tony
got root?
Stuart Browne
Honored Contributor

Re: Filename Completion and History

usually ESC+ESC is the equivalent to TAB in a bash shell.

To do partial-name-listings however, it seems you have to press escape 5 times instead of four.. but that's in 'set -o emacs'.

As you're in 'set -o vi', you should be using the ksh/vi key equivalents, ESC+\ (for completion) and ESC+* (for all matches).
One long-haired git at your service...