How to execute the output of a command within the current shell?

前端 未结 9 1165
渐次进展
渐次进展 2020-12-04 07:37

I\'m well aware of the source (aka .) utility, which will take the contents from a file and execute them within the current shell.

Now, I\'

9条回答
  •  抹茶落季
    2020-12-04 08:15

    $ ls | sed ... | source /dev/stdin
    

    UPDATE: This works in bash 4.0, as well as tcsh, and dash (if you change source to .). Apparently this was buggy in bash 3.2. From the bash 4.0 release notes:

    Fixed a bug that caused `.' to fail to read and execute commands from non-regular files such as devices or named pipes.

提交回复
热议问题