Unix Shell - BASH: Can bash do this?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2006 > BASH: Can bash do this?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author BASH: Can bash do this?
hantechs@gmail.com

2006-12-18, 1:37 am

I input a long command in bash, and then I found I must run some other
command such as man, but I must not run this long command to save it in
the history, because it may harmful, Is there a way to save it in the
history without running it?

Grant

2006-12-18, 1:37 am

On 17 Dec 2006 19:10:48 -0800, "hantechs@gmail.com" <hantechs@gmail.com> wrote:

>I input a long command in bash, and then I found I must run some other
>command such as man, but I must not run this long command to save it in
>the history, because it may harmful, Is there a way to save it in the
>history without running it?


#comment the long command, hit enter...

Grant.
--
http://bugsplatter.mine.nu/
megadave@gmail.com

2006-12-18, 1:37 am


Grant wrote:
> On 17 Dec 2006 19:10:48 -0800, "hantechs@gmail.com" <hantechs@gmail.com> wrote:
>
>
> #comment the long command, hit enter...


Additional options..

1. Run the man command in another vty/window/terminal?

2. Copy/paste the 'long command' to a text editor in another
vty/window/terminal?

>
> Grant.
> --
> http://bugsplatter.mine.nu/


Stephane CHAZELAS

2006-12-18, 7:22 am

2006-12-17, 19:10(-08), hantechs@gmail.com:
> I input a long command in bash, and then I found I must run some other
> command such as man, but I must not run this long command to save it in
> the history, because it may harmful, Is there a way to save it in the
> history without running it?


Don't know about bash, but with zsh:

<Meta-Q> saves the current command line to let you enter another
one.

<Meta-H> goes far beyond that. Not only it saves the current
command line but it brings you all the help available on the
command you're trying to run.

Both will automatically bring your saved command line to you
after the man command is finished, you don't need to bring it
back from the history.

--
Stéphane
Chris F.A. Johnson

2006-12-18, 7:22 am

On 2006-12-18, hantechs@gmail.com wrote:
> I input a long command in bash, and then I found I must run some other
> command such as man, but I must not run this long command to save it in
> the history, because it may harmful, Is there a way to save it in the
> history without running it?


history -s "A long command"
history -a

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
Random832

2006-12-18, 1:20 pm

2006-12-18 <1166411448.524517.174500@79g2000cws.googlegroups.com>,
hantechs@gmail.com wrote:
> I input a long command in bash, and then I found I must run some other
> command such as man, but I must not run this long command to save it in
> the history, because it may harmful,


What I do when I run into this situation is hit ^U to cut the command,
then after i've run man or whatever, hit ^Y to paste. You have to be
careful what else you delete, because some other delete actions (not
backspace - but ^W for instance) will replace this "clipboard"-like
thing that bash uses.

> Is there a way to save it in the history without running it?


You could save it as a comment, I suppose. My way is almost automatic
for me now, and it works also on IRC chat etc.
Peter Gantner

2006-12-20, 1:18 pm

On Monday 18. December 2006 04:31, Grant spoke to comp.unix.shell:

> On 17 Dec 2006 19:10:48 -0800, "hantechs@gmail.com" <hantechs@gmail.com>
> wrote:
>
>
> #comment the long command, hit enter...

ESC-# does exactly those two things.
AFAIK works in both vi and emacs input modes, as well as in other shells
like ksh.

Peter

--
"I do not think the way you think I think."
-- Kai, last of the Brunnen G
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com