Score:0

grep and pipe combination to filter standat input

ml flag

Why this is working

gdbus monitor -y -d org.freedesktop.login1 | grep org

Filtering output lines containing "org"

This is working

gdbus monitor -y -d org.freedesktop.login1 | (while read LINE ; do echo "$(date) $LINE" ; done)

Printing date before line output

But this is not working.

gdbus monitor -y -d org.freedesktop.login1 | grep org | (while read LINE ; do echo "$(date) $LINE" ; done)

The intention here is to print out date before line output only for lines containing "org"

hr flag
Try `grep --line-buffered` - see for example [What does grep line buffering do?](https://askubuntu.com/questions/562344/what-does-grep-line-buffering-do) and [Read logs real time with bash](https://askubuntu.com/a/1395229/178692)
cc flag
Or kill the gdbus process and let the buffers flush: kill -s INT `pidof gdbus`
Alex avatar
ml flag
--line-buffered helps, thanks
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.