Re: pasting text into bash without use of mouse
On Sunday 08 April 2001 08:48, Karsten M. Self wrote:
> on Sun, Apr 08, 2001 at 07:38:11AM +0800, csj (csj@mindgate.net)
wrote:
> > On Friday 06 April 2001 03:04, Karsten M. Self wrote:
> > > on Thu, Apr 05, 2001 at 06:47:53AM +0800, csj
> > > (csj@mindgate.net)
> >
> > wrote:
> > > > On Wednesday 04 April 2001 09:41, Karsten M. Self wrote:
> > > > > csj (csj@mindgate.net) wrote:
> > > > > > Is there a way to copy or paste text into bash without
> > > > > > the use of a mouse? I'm thinking of a text file
> > > > > > "file.txt" which contains command sequences which I would
> > > > > > like to touch up before running.
> > > > > >
> > > > > > I don't want to use an editor for this. Just the line
> > > > > > editing functions of bash. Offhand the only (untested)
> > > > > > solution I can think of is something like "cat file.txt
> > > > > > >> .bash_history", subsequently invoking another bash
> > > > > > session. Is this stupid (dangerous)? Does someone have a
> > > > > > better solution?
> > > > >
> > > > > Just posted here this week. If you have wmaker installed,
> > > > > wxpaste and wxcopy do what you'd expect them to.
> > > >
> > > > It looks interesting. But I forgot to add: --without-X. For
> > > > those dire moments when X crashes.
> > >
> > > I'm no longer clear on what it is you're hoping to accomplish.
> > > More below.
> >
> > Taking a breath of humid air:
> >
> > Let's say I have a file "commands.list" which contains a series
> > of commands. One is the line:
> >
> > (1) find * -name *.htm | grep -h "http://www.foo.org" > foo.txt
> >
> > I want now to do:
> >
> > (2) find * -name *.htm | grep -h "http://www.foobare.org" >
> > foo.txt
> >
> > I would extract the first command (1) from "commands.list" by
> > typing
> >
> > grep "www.foo.org"
> >
> > which would of course print to the default stdout, e.g. the
> > terminal. End of story. That's all I get. But if there's some way
> > to "pipe" or "paste" (note the quotes of doubt) the output of
> > grep and friends to the command line itself, I can simply use
> > bash's line-editing functions to morph command (1) to command
> > (2). No mousing around (admittedly not much of a gray-xercise
> > when you're using gpm or X), no retyping, no vi.
>
> Command Substitution:
>
> $ cat <<EOF >cmd.lst
> df
> ls
> uptime
> EOF
>
> $ $( grep df cmd.lst )
>
> QED.
Not quite QED (tho quite close). What I'm looking for is how to edit
and execute an EXISTING cmd.lst. Sorry if I'm missing something
perfectly obvious. Hope this is the penultimate strand on this thread.
Reply to: