2014-10-08 55 views

回答

3
gsettings2 ... | stdbuf -oL cut -f2 -d "'" | while read -r uri; do 
    foo "$uri" 
done 

while read环路读取每个URI调用foostdbuf -oL调用在那里强制cut被行缓冲,因此其输出立即可见。

+0

嗨,谢谢你的回复。我自己尝试这个,但由于某种原因,这不起作用。更新的问题。请注意[gsettings monitor](https://developer.gnome.org/gio/stable/gsettings-tool.html)本身就是一个无限循环。 – prakharsingh95 2014-10-08 21:19:31

+0

我不明白的是,如果切割工作,为什么不是这样。 – prakharsingh95 2014-10-08 21:26:13

+0

如果你执行'stdbuf -oL cut -f2 -d''“'有帮助吗?问题可能是'cut'的输出是完全缓冲的。如果stdbuf帮助让我知道,我会将其添加到我的答案。 – 2014-10-08 22:19:33

相关问题