0

This bash script returns nothing, but the exact same script ran in a oneliner returns the correct output.

#!/bin/bash

URL="localhost:3000"
content=$(curl -s $URL | sed -E 's/<[^>]*>//g')
vidsWatched=$(echo $content | grep -A 3 "Videos Watched" | sed -n 4p)
echo "$vidsWatched"

Vs the onliner:

curl -s "http://localhost:3000" | sed -E 's/<[^>]*>//g' | grep -A 3 "Videos Watched" | sed -n 4p

Output:

600

0 Answers0