How do I paste multi-line bash codes into terminal

2020-02-16 06:49发布

I need to paste a multi-line bash code into terminal, but whenever I do, each line gets run as a separate command as soon as it gets pasted.

10条回答
2楼-- · 2020-02-16 07:22

In addition to backslash, if a line ends with | or && or ||, it will be continued on the next line.

查看更多
我想做一个坏孩纸
3楼-- · 2020-02-16 07:23

To prevent a long line of commands in a text file, I keep my copy-pase snippets like this:

echo a;\
echo b;\
echo c
查看更多
看我几分像从前
4楼-- · 2020-02-16 07:28

Try putting \ at the end of each line before copying it.

查看更多
该账号已被封号
5楼-- · 2020-02-16 07:30

Try this way:

echo $( 
    cmd1
    cmd2
    ...
)
查看更多
登录 后发表回答