nak req -k 7 -l 0 --stream wss://relay.damus.io | jq -r '.content'

works as intended

nak req -k 7 -l 0 --stream wss://relay.damus.io | jq -r '.content'

| while IFS= read -r line; do

echo "Latest: $line"

done

and nothing is ever sent to $line

nak outputs to stdout does it not? Works fine without --stream, but something about that...need to figure out how it writes that output.

Has anyone gotten piped output from #nak to work (whilst in event stream mode)

https://dl.vanderwarker.family/videos/nostr/nak_stream_pipe.webm

#bash #asknostr

Reply to this note

Please Login to reply.

Discussion

Try tail -f ing the jq?

Before the while loop?

It won't output anything.

I don't actually know how this works, sorry

Nah it's all good it's been a couple of days being like damn it...no

.. try something else....no 😂

I'll get there eventually 😁☺️

Mite be necrothreading here but here goes:

```

#!/bin/bash

RED_BOLD='\033[1;31m'

RESET='\033[0m'

nak req -q -k 1 wss://nos.lol --stream 2>/dev/null | while read -r line; do

pubkey=$(echo "$line" | jq -r '.pubkey')

metadata=$(nak req -k 0 -a "$pubkey" wss://nos.lol 2>/dev/null | head -n 1)

username=$(echo "$metadata" | jq -r '.content | fromjson | .name // .display_name // "'"$pubkey"'"')

time=$(echo "$line" | jq -r '.created_at | todate')

content=$(echo "$line" | jq -r '.content')

printf "\n-------------\n${RED_BOLD}Time:${RESET} %s\n${RED_BOLD}PubKey:${RESET} %s\n${RED_BOLD}Username:${RESET} %s\n${RED_BOLD}Post:${RESET} %s\n" "$time" "$pubkey" "$username" "$content"

done

```

YEAH! That was it! Thank you so much!!

Awesum, glad it worked for ya! 😎

bash/sed/awk + nak is truly the greatest nostr tool.