开发者

How to pipe information into a buffer to recall in unix shell

开发者 https://www.devze.com 2023-02-09 03:45 出处:网络
I want to know how to pipe t开发者_开发问答ext from a cat or anything so i can use it as a variable.If using bash​:

I want to know how to pipe t开发者_开发问答ext from a cat or anything so i can use it as a variable.


If using bash​:

FOO=$(cat foo)


if using bash, no need cat

var=$(<file)


i hope i understood you.
u can pipe to stdin with FIRST_COMMAND | SECOND_COMMAND.
if you want to use really variable u should write

$var=`COMMAND`


Set the variable to the result of a command using ' characters, like this:

$ var='cat foo'

This approach works in most shells.

0

精彩评论

暂无评论...
验证码 换一张
取 消