简体   繁体   中英

How do I redirect output text back into the command line in Linux?

How do I redirect the output and redirect it back into the input. Basically to automatically type the text outputted, into the command line.

Like this command:

$ locate ifcfg-eth0

would normally output:

$ /etc/sysconfig/network-scripts/ifcfg-eth0

instead of clearing the command and creating a new line I want it to do this

$ /etc/sysconfig/network-scripts/ifcfg-eth0(cursor blinking here)

We can do something like this with a tool named xclip

install xclip on debian

sudo apt-get install xclip

now use

locate ifcfg-eth0 | xclip

to paste the output use

xclip -o

For example: I have a file named scp.sh. I want to locate and run it.

locate scp.sh | xclip

then

xclip -o | bash

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM