开发者

error on pipe in bash script

part of my bash script is

A="-a"开发者_Python百科
B="|more"
ls $A $B

when executing this script, it complained "|more" not found. How to use pipelines in bash script commands then please?


Maybe like this:

eval "ls $A $B"

?


I think what you may be trying for is implementing some sort of variable that controls whether the data is piped through a pager.

You may be better off using alias:

if [ "$USING_PAGER" -ne 0 ]; then
    alias B='more'
else
    alias B='cat'
fi

ls $A |B


ls -a |more

also fails - there is no such command in bash.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜