简体   繁体   中英

How to redirect output of a bash script to screen on the fly?

I'm running a one-line script that should have multi-stage output:

#!/bin/bash

ansible-playbook deploy-master.yml -i ./inventories --private-key=$HOME/.ssh/id_rsa

however it won't show anything until its execution is finished (after which it will print all outputs of ansible-playbook). How do I fix this?

It seems like the easiest solution is to switch shebang line to:

!/usr/bin/env bash

I don't know the reason but it just worked.

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