[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using terminal output as input

Dotan Cohen wrote:
> I am baffled that one must type in the output to commands. For
> instance, the sysadmin may need to use the existing DHCP IP address
> for one reason or another. After running ifconfig, where the address
> is stated, why must he type it in? I'm not looking for copy-paste in
> the GUI sense, but some sort of this-to-there method for carrying
> small bits of data seems so useful, basic, and would help prevent
> typos.

As other people have pointed out, the way to capture a command's output
is with $(command) (or `command`, though this is a bashism). However,
unless the output is exactly in the form you need (which is often not
the case; in your example ifconfig outputs a lot of information besides
the IP address), the time it takes to come out with a command line that
filters only the part you need (using tools such as head, tail, cut,
etc.) is probably much greater than the time needed to type the
information again --- or cut and paste, if this is something you'll only
do a couple of times.

Your supervisor is thinking about you.


Reply to: