Re: Using terminal output as input
On Thu, May 14, 2009 at 11:08:14AM -0400, S Scharf wrote:
> On Thu, May 14, 2009 at 10:55 AM, Dotan Cohen <dotancohen@gmail.com> wrote:
>
> > I am using a Debian-based distro (Ubuntu). Often I need to use the
> > output of one terminal command as the input for another. A classic
> > example is the which command:
> > $ which firefox
> > /usr/bin/firefox
> > $
> >
> > Now, I would like to use that output as input, to start firefox. Other
> > than manually typing it in, is there a way for the user to use the
> > output directly?
> >
> > Another example is when the OS lets the user know that she needs to
> > install a program and gives her the command to install it:
> > $ ekiga
> > The program 'ekiga' is currently not installed. You can install it by
> > typing:
> > sudo apt-get install ekiga
> > bash: ekiga: command not found
> > $
>
>
> Not pretty but how about
> `ekiga | head -2 | tail -1`
Also note that
$(ekiga | head -2 | tail -1)
is a more portable equivalent. $() is the same as `` but unlike `` can
be nested, and has less quoting issues. You can enclose it in
double quotes, for example since it behaves like a variable expansion.
Regards,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
Reply to: